我有一个nginx集群,作为一个API路由器,代理近400万个请求。 我们有一个问题,上游连接将超时一段时间,然后nginx工作进程将会死亡,并成为孤儿。
2017/10/06 18:21:32 [error] 10908#0: *203159041 upstream timed out (110: Connection timed out) while connecting to upstream, client: 10.2.2.2, server: , request: "POST /api/path/v1 HTTP/1.1", upstream: "http://10.1.1.1:80//api/path/v1", host: "example.com" 2017/10/06 18:21:42 [alert] 3403#0: worker process 10911 exited on signal 11 2017/10/06 18:21:43 [alert] 3403#0: worker process 10913 exited on signal 11
这是我的nginx.conf的相关部分。 上游块不包括在内但只有服务器值。
user nginx; worker_processes 8; pid /var/run/nginx.pid; worker_rlimit_nofile 70000; events { worker_connections 16384; use epoll; } http { client_body_temp_path /var/openresty/nginx/cache_b/client_body; proxy_temp_path /var/openresty/nginx/cache_b/proxy_path; client_max_body_size 150m; include mime.types; default_type application/json; keepalive_timeout 30; proxy_read_timeout 200; proxy_connect_timeout 30; sendfile on; tcp_nopush on; tcp_nodelay on; gzip on; gzip_proxied any; gzip_types application/json application/xml text/plain text/xml; server_tokens off; proxy_next_upstream error;
我已经阅读了很多nginx调优文章,并做了相当多的修改,但是现在我只是在黑暗中拍摄而已。 也许我应该增加proxy_connect_timeout值?