如何减少等待连接的时间

如何减少等待连接的时间

我在 Linux(Debian)上运行 Comet 服务器。
所有连接都由 nginx 代理。
尽管我设置了 repeat_connections,但我的 time_wait/es​​tablished 比率太大(50k/15k)。
我想减少 time_wait 状态下的大量不需要的连接。
这是我的 sysctl.conf 规则:

net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_keepalive_time = 60
net.ipv4.tcp_fin_timeout = 3
net.ipv4.tcp_max_tw_buckets = 360000
net.ipv4.tcp_keepalive_probes=3

您能给我一些关于如何减少 time_waits 的提示吗?

答案1

net.ipv4.tcp_max_tw_buckets = 360000

为什么当您允许 360K 个套接字时,TIME_WAIT 中有 50K 个套接字会成为一个问题?

相关内容