[alibaba/tengine]tengine-2.3.2 做 TCP 负载均衡,执行 reload 后,worker process 不释放

2024-05-15 843 views
8

tengine-2.3.2 做 TCP 负载均衡,执行 reload 后,worker process 不释放(过了一个晚上都没释放)。 nginx 配置信息: ----------nginx.conf--------------- user nobody; worker_processes 4; worker_rlimit_nofile 65535; error_log /opt/logs/nginx/error.log info; pid /opt/run/nginx/nginx.pid; events { worker_connections 65535; } stream {

log_format  main  '[$time_local] $remote_addr '
                  '$protocol $status '
                  '$session_time $upstream_addr '
                  '$upstream_connect_time';

access_log  /opt/logs/nginx/access.log main gzip flush=5m;

upstream elasticsearch {
    server 192.168.1.82:9300 max_fails=1 fail_timeout=120s weight=1;
    server 192.168.1.93:9300 max_fails=1 fail_timeout=120s weight=1;
    server 192.168.1.94:9300 max_fails=1 fail_timeout=120s weight=1;
    server 192.168.1.173:9300 max_fails=1 fail_timeout=120s weight=1;
    server 192.168.1.174:9300 max_fails=1 fail_timeout=120s weight=1;
}

server {
    listen 9300;
    error_log /opt/logs/nginx/es_error.log debug;
    access_log /opt/logs/nginx/es.log main gzip flush=10m;

    proxy_timeout 120s;
    proxy_connect_timeout 120s;
    proxy_buffer_size 128k;
    proxy_next_upstream on;
    proxy_next_upstream_timeout 10s;
    proxy_pass elasticsearch;
}

}

回答

2

Tengine/Nginx reload由于是平滑的,老的的worker之所以长时间不退出是由于其进程上还存在相关事件(比如定时器、长连接等),可以使用 worker_shutdown_timeout配置老的worker强制退出时间。

3

nginx-1 哦,我没有配置长连接。仅作 elasticsearch 之 TCP 端口负载均衡,都是短连接。用做 http 负载均衡reload 后,老的 worker process 处理完之后就会退出。从日志来看,worker process 对应的子进程后续都没继续处理任何任务了。