继:https://www.iyunw.cn/archives/xie-lin-lin-jiao-xun-sheng-cheng-huan-jing-bu-yao-luan-xiu-gai-net-ipv4-tcp-tw-recycle/
关闭tcp_tw_reccycle 后,又大面积出现的time-wait,仔细观察连接发现全是nginx和Tomcat之间的连接time-wait,搜索了N多资料发现可以通过修改反向代理长连接超时时间控制,具体使用方法
upstream http_backend { server 127.0.0.1:8080; keepalive 16; #设置长连接超时时间 } server { ... location /http/ { proxy_pass http://http_backend; proxy_http_version 1.1;#http协议1.1 proxy_set_header Connection ""; #空header ... } }
时间自己定义,设置完后,发现time-wait立马就全部下降了,nginx官网说明文档:
http://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive
评论区