Transferred from: http://www.cnblogs.com/Bozh/p/3752476.html
Operation and maintenance of the classmate and team inside a classmate have encountered Nginx on-line environment use will encounter time_wait or close_wait too high state
First of all, the reason why, the problem is solved.
The first is time_wait:
Understand the cause of the TIME_WAIT state, this problem has been a lot of books say rotten, but why many people still can't solve, the reason or because
Most of them are academics, and have not really encountered such problems, because a lot of time_wait are occurring in the actual application environment.
The reason for the time_wait is due to the active shutdown of the server during the communication process, and after the last fin packet is sent to the server, the system waits for double time
The MSL (Max Segment Lifetime) is used to wait for the client to send over the Fin_ack and fin, this time the service side of the corresponding socket FD is not able to re-
Use, so in a large number of short-connection services, there will be too much time_wait phenomenon.
Solution:
Adjust the time_wait time-out period
123456 |
net.ipv4.tcp_tw_reuse = 1 表示开启重用。允许将TIME-WAIT sockets重新用于新的TCP连接,默认为0,表示关闭; net.ipv4.tcp_tw_recycle = 1 表示开启TCP连接中TIME-WAIT sockets的快速回收,默认为0,表示关闭。 net.ipv4.tcp_fin_timeout = 20 |
About the online environment close_wait and time_wait too high