Time-Wait sockets quick recovery

Source: Internet
Author: User

Time-Wait
Quick Recovery of sockets

Source http://www.xymyeah.com/494.html


I found a large number of time-Wait connections on my server, which can reach tens of thousands. By modifying kernel parameters, the system can quickly reclaim time-Wait sockets.


View TCP connections:

[Root @ centos ~] # Netstat-N | awk '/^ TCP/{++ s [$ NF]} end {for (a in S) print a, s [a]}'
Last_ack 56
Syn_recv 77
Established 11213
Fin_wait1 4013
Fin_wait2 1638
Closing 3
Time_wait 12261


Modify kernel parameters to quickly recycle time_wait sockets:

[Root @ centos ~] # Echo "net. ipv4.tcp _ tw_reuse = 1">/etc/sysctl. conf
# Indicates enabling reuse. Allow time-Wait sockets to be re-used for a New TCP connection. The default value is 0, indicating that the TCP connection is disabled;
[Root @ centos ~] # Echo "net. ipv4.tcp _ tw_recycle = 1">/etc/sysctl. conf
# Indicates to enable quick time-Wait sockets recovery in TCP connections. The default value is 0, indicating to disable time-Wait sockets.
[Root @ centos ~] # Sysctl-P


After the modification is complete, check the TCP connection status. The time-Wait connection is significantly reduced, and it seems that Apache access is much faster.

[Root @ centos ~] # Netstat-N | awk '/^ TCP/{++ s [$ NF]} end {for (a in S) print a, s [a]}'
Last_ack 26
Syn_recv 225
Established 9228
Fin_wait1 4002
Fin_wait2 611
Closing 2
Time_wait 415 http://www.xymyeah.com/494.html more

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.