If nginx proxy is used, the number of TIME_WAIT instances in the system will increase. This is because the nginx proxy uses short links to interact with the backend, this makes nginx and the backend ESTABLISHED very small, while there are many TIME_WAIT instances. This not only happens on the proxy server where nginx is installed, but also causes a large number of TIM
If nginx proxy is used, the number of TIME_WAIT instances in the system will increase. This is because the nginx proxy uses short links to interact with the backend, this makes nginx and the backend ESTABLISHED very small, while there are many TIME_WAIT instances. This not only happens on the proxy server where nginx is installed, but also causes a large number of TIME_WAIT instances on the backend app server. Looking at TIME_WAIT materials, I found that this status is not a big problem, but it may be because it occupies too many ports in the system, leading to the failure of subsequent requests to obtain ports.
Although TIME_WAIT may cause some problems, it is unfair to completely kill it, although it seems that there is nothing wrong with doing so. For details, refer to this document:
Http://hi.baidu.com/tim_bi/blog/item/35b005d784ca91d5a044df1d.html
So it seems that the best way is to make every TIME_WAIT expire earlier.
This configuration can be performed on linux:
# Enable the TIME_WAIT status to be reused, so that new requests will not be rejected even if TIME_WAIT is full of all ports.
Echo 1>/proc/sys/net/ipv4/tCp_ Tw_reuse
# I don't know how long it will take for TIME_WAIT to be recycled as soon as possible. It may take about one second to observe.
Echo 1>/proc/sys/net/ipv4/tcp_tw_recycle
We recommend that you configure both parameters in many documents, but I found that you can solve the problem by modifying tcp_tw_recycle. We do not recommend you enable TIME_WAIT to reuse the TCP protocol.
If you cannot reuse a port, some services in the system may fail to be started. For example, if you want to restart a software monitored by the system, port 40000 is used, if the port is used during software restart, the restart may fail. This problem is taken into account by default in linux. The following settings are available:
# Viewing the limit value of the local available ports of the system
Cat/Proc/sys/net/ipv4/ip_local_port_range
Use thisCommandTwo numbers are returned. The default value is 32768 61000. This indicates that the local machine can connect 61000-32768 = 28232 connections. Note that the local connection is external, not all connections of this machine, does not affect the number of external connections on port 80 of this machine. However, this number affects the maximum number of connections from the proxy server (nginx) to the app server, because nginx uses asynchronous transmission for the app, so the connection speed in this link is very fast, therefore, there are few stacked connections. If nginx has a problem with the bandwidth between app servers or the app server has a problem, the connection may pile up. In this case, you can set the nginx proxy timeout time, to release the connection as soon as possible. Generally, 28232 connections are rarely used.
Because some software uses port 40000 for listening, if errors occur frequently, you can set the minimum value of ip_local_port_range to solve the problem:
Echo 40001 61000>/proc/sys/net/ipv4/ip_local_port_range
However, this obviously reduces the number of available ports in the system. In this case, you can tune up the maximum value of ip_local_port_range. But it is recommended that you use a port of no more than 32768 to listen for the service, in addition, you do not need to modify the value of ip_local_port_range to 1024 or 65535, which is of little significance.
Because nginx proxy is used, a large amount of TIME_WAIT is also generated in windows. Of course, windows can also be adjusted as follows:
In the Registry (regEdIt) HKEY_LOCAL_MACHINESYSTEMCurrentConTrAdd a DWORD Value TcpTimedWaitDelay on olSetServicesTcpipParameters. The value is in seconds.
In windows, TIME_WAIT is reused by default. I still don't know how to change it to be reused, and I haven't found any value for the local port. However, these are not relevant and can all work by default.
Take a look at this document:
Http://morganchengmo.spaces.live.com/blog/cns! 9950CE918939932E! 1721. entry