During the stress test, there were a large number of
TIME_WAIT connections on the Web Server, coming from Nginx.
TIME_WAIT is an intermediate state during the 4 waves of the TCP protocol, which all disappear after a while.
There are two doubts here.
- the number of connections in the
TIME_WAITstate exceeds the number of concurrent JMeter connections (500).
- the JMeter scripts have Keep-Alive enabled.
This phenomenon looks like the Nginx -> Web Server connection is not kept Alive, causing the connection to be re-established and then disconnected for each request.
Check the Nginx configuration file.
As you can see, the keepalive directive has been configured, but it does not appear to be in effect.
However, a look at the documentation for the keepalive directive shows that it needs to be used with the
Connection request header set to
And the actual Connection looks like this.
Why do you configure it this way? This is a copy of the official blog of Nginx about proxy Websocket.
According to the above configuration, the value of
Connection is actually
close, which is why every request disconnects, and then a new request creates a connection, resulting in a lot of
TIME_WAIT TCP connections.
The problem is solved by changing the
map directive to the following.