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 , .


2 Responses

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

  1. iHao says

    还真没试过,试试去

  2. leopku says

    兄弟,试试CentOS Tweak(http://www.himysql.com/linux/centos-tweak.html)
    常用的内核优化、网络优化、磁盘优化等等都集成在一个脚本里,装完机器跑一下脚本,这些优化都完成了。



Some HTML is OK

or, reply to this post via trackback.