Skip to content


优化web服务器tcp半连接

在繁忙的web服务器上,很常见的问题是大量tcp 半连接的存在占用系统的大量资源。有效的减少半连接对优化服务器响应有着重要的作用。
实践步骤:

1。执行 /bin/netstat -n | awk ‘/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}’
2。vi /etc/sysctl.conf 添加如下两行:

1)net.ipv4.tcp_tw_reuse = 1 //允许将TIME-WAIT sockets重新用于新的TCP连接
2)net.ipv4.tcp_tw_recycle = 1 //开启TCP连接中TIME-WAIT sockets的快速回收


3。运行sysctl -p

4。执行 /bin/netstat -n | awk ‘/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}’

如果对于TIME_WAIT较高的服务器来说应该很快就会看到效果

Posted in Web开发, linux.

Tagged with , .


One Response

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. iHao says

    还真没试过,试试去



Some HTML is OK

or, reply to this post via trackback.