Linux time_wait Reduction Method

Source: Internet
Author: User
Linux time_wait reduction method-Linux Enterprise Application-Linux server application information. The following is a detailed description. Check the number of Apache connections and sometimes find many useless Time_Wait connections. Some people say this is normal because a request is interrupted midway through; others say that Microsoft's IE connection will generate more Time_wait than Firefox connection. I personally think that it is normal to have a certain Time_wait. If the percentage of connections exceeds the limit, it is not normal, so I should find a solution.

Check the current net. ipv4.tcp _ tw value and change the current value to 1 minute:
[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

Add or modify the net. ipv4.tcp _ tw value:
Net. ipv4.tcp _ tw_reuse = 1
Net. ipv4.tcp _ tw_recycle = 1

Make kernel parameters take effect:
[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

Set these two parameters: reuse indicates whether to allow re-application of a socket in the TIME-WAIT status to be used for a New TCP connection; recyse indicates accelerating TIME-WAIT sockets collection

Use netstat to check again
The key to solving the problem here is how to reuse the value of time_wait. We can check the value of time and 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

This phenomenon is actually normal. Sometimes it is related to a large amount of traffic. Set the two parameters: reuse indicates whether to allow re-application of the socket in the TIME-WAIT Status for New TCP connections; recyse accelerates TIME-WAIT sockets collection.

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.