Tuning of Linux kernel parameters (careful use in production)
Solutions to the emergence of a large number of TIME_WAIT in Linux
In practical work, it is best to let the operation and maintenance staff adjust it.
View command: netstat-ae | grep "TIME_WAIT" | wc-l
Solve the problem by adjusting the kernel parameters: vi / etc/sysctl.conf, add the following
Net.ipv4.tcp_tw_reuse = 1
Enable reuse, allowing TIME-WAIT sockets to be reused for new TCP connections
Net.ipv4.tcp_tw_recycle = 1
Enable fast recovery of TIME-WAIT sockets in TCP connection
Net.ipv4.tcp_fin_timeout = 30
Modify the system default TIMEOUT time
Net.ipv4.tcp_keepalive_probes = 5
Reduce the number of detections before timeout
Net.ipv4.tcp_keepalive_intvl = 20
Detect the frequency of messages sent
Net.ipv4.ip_local_port_range = 1024 65000
Represents the range of ports used for outbound connections
Net.ipv4.tcp_max_syn_backlog = 8192
Indicates the length of the SYN queue. The default is 1024. When it is enlarged, it can accommodate more network connections waiting to be connected.
Net.ipv4.tcp_syncookies = 1
Enable SYN Cookies. When there is a SYN waiting queue overflow, enable cookies to handle it to prevent a small amount of SYN***.
Then execute / sbin/sysctl-p to make the parameter take effect