轉:Linux下解決APACHE的TIME_WAIT串連太多問題__Linux

來源:互聯網
上載者:User

http://blog.chinaunix.net/u/26011/showart_332604.html

  前言:經常檢查Apache的串連數,同樣會發現很多無用的Time_Wait串連。有人說這是正常的,是因為一個請求中途中斷造成的;還有人說微軟的IE串連時產生的Time_wait會比用Firefox串連時多。個人認為有一定的Time_wait是正常的,如果超過了串連數的比例就不是很正常,所以還是找來方法解決一下。       檢查net.ipv4.tcp_tw當前值,將當前的值更改為1分鐘:
[root@aaa1 ~]# sysctl -a|grep net.ipv4.tcp_tw
net.ipv4.tcp_tw_reuse = 0
net.ipv4.tcp_tw_recycle = 0
[root@aaa1 ~]#

vi /etc/sysctl
增加或修改net.ipv4.tcp_tw值:
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1

使核心參數生效:
[root@aaa1 ~]# sysctl -p

[root@aaa1 ~]# sysctl -a|grep net.ipv4.tcp_tw
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1

設定這兩個參數: reuse是表示是否允許重新應用處於TIME-WAIT狀態的socket用於新的TCP串連; recyse是加速TIME-WAIT sockets回收

用netstat再觀察正常
這裡解決問題的關鍵是如何能夠重複利用time_wait的值,我們可以設定時檢查一下time和wait的值
#sysctl -a | grep time | grep wait
net.ipv4.netfilter.ip_conntrack_tcp_timeout_time_wait = 120
net.ipv4.netfilter.ip_conntrack_tcp_timeout_close_wait = 60
net.ipv4.netfilter.ip_conntrack_tcp_timeout_fin_wait = 120

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.