1,
Number of time_wait after parameter adjustment
Modify the Linux kernel parameters to reduce time_wait in TCP connections
The impact of kernel parameter tuning on Web performance in Web system is huge, and the related perception needs to be experienced!!
In the case of limited resources (cpu/memory), the use of tuning kernel-related parameters can greatly improve the performance of the web system, optimize the access experience-browser Web site response-visual perception ...
Responsibility and performance issues that cannot be resolved by modifying the relevant kernel parameters need to be upgraded by upgrading resources
Linux system, after the TCP/IP connection is disconnected, the TIME_WAIT state will be retained for a certain amount of time (why? Many-tcp_tw_reuse ...)
Assuming a large amount of concurrent web Concurrency, this will result in a large number of time_wait state connections, and the inability to disconnect these connections in a timely manner consumes a lot of server resources (if time_wait closed;process exit and resource Release
In this case, you can consider optimizing the TCP/IP kernel parameters to clean up the ports of the TIME_WAIT state in time
Linux system view current TCP/IP connection status and corresponding number
#netstat-na | awk '/^tcp/{++s[$NF]} END {for (a in s) print A,s[a]} '
/etc/sysctl.conf
net.ipv4.tcp_syncookies = 1 #表示开启SYN cookies, when there is a SYN wait queue overflow, cookies are enabled to protect against a small number of SYN attacks, the default is 0, which means close
Net.ipv4.tcp_tw_reuse = 1
Represents turn on reuse, allowing time_wait sockets to be reused for new TCP connections, which defaults to 0
Net.ipv4.tcp_tw_recycle = 1
Net.ipv4.tcp_fin_timeout = 5
Linux Web Performance optimization