我们有一个绑定到一个IP的Nginx反向代理(RP),负载均衡/故障转移到两个IP,这些IP位于networking时间大约140ms的地方。 每个上游IP位于不同的ISP上,但绑定到PFsense盒子上的接口。 PFsense框使用NAT将传入的HTTP连接转换为内部Microsoft NLB IP,然后绑定到一些服务于实际请求的Web服务器。 我怀疑pfsense或iis与这件事有什么关系,但是我提到他们,以防万一你们有一些洞察力,这些洞察力可能是其中的一部分。
对于〜10 req / s的基线stream量,这个configuration工作正常。 但是,我们的使用案例处理的stream量高峰往往达到〜200瑞奇/秒。 发生这种情况时,所有地狱都会松动。 nginx错误日志开始填满以下的吨:
上游超时(110:连接超时)连接到上游
偶尔还有其中一些:
连接()失败(113:没有路由到主机),而连接到上游
不久之后,nginx收集了足够多的这些数据,以确定其中一个或两个上游是否“closures”,然后开始向客户端发送503或504错误消息,但是在放慢到完全无法使用的范围之前。
在此期间,盒子上的平均负载不超过0.15,并且CPU使用率接近5%。 反向代理和上游都有足够的可用带宽。
我已经查看了nginx错误提供的答案:上游超时(110:连接超时),但它们不反映我的情况。 如果将反向代理从等式中排除,并试图直接强调上游服务器,则上游服务器将完美处理所有请求。
这里是我的nginxconfiguration中的相关行:
worker_processes 8; # I have 8 cores on this box, so this should be right events { worker_connections 768; } sendfile on; tcp_nopush on; # tried both settings, doesn't matter keepalive_timeout 65; tcp_nodelay off; # tried both settings, doesn't matter gzip on; upstream tcinstances { server [ip_removed] weight=1 max_fails=10 fail_timeout=30s; # tried default/different max_fails, same result server [ip_removed] weight=1 max_fails=10 fail_timeout=30s; } proxy_cache_path /var/www/cache levels=1:2 keys_zone=tc-cache:4m max_size=128m inactive=600m; proxy_temp_path /var/www/cache/tmp; server { listen 80; server_name drp; proxy_buffering on; # tried this off, also, doesn't change anything proxy_read_timeout 30s; proxy_connect_timeout 2s; # I know this looks low, but if I set this to 60s or default, all requests become *extremely slow* immediately, and they eventually time out anyway. at least this way it fails fast. proxy_next_upstream error timeout; location / { proxy_pass http://tcinstances; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; expires 1s; add_header Cache-Control public,max-age=604800,post-check=604800,pre-check=1209600; } location ~* ^.+\.(png|jpg|gif|css|js)$ { proxy_pass http://tcinstances; proxy_set_header Host $http_host; proxy_cache tc-cache; proxy_cache_valid 200 302 60m; proxy_cache_valid 404 1m; proxy_cache_key "$scheme$host$request_uri"; access_log off; expires 1d; } }
任何帮助搞清楚这将是绝对赞赏。 谢谢。