When a VPS or Dedicated hosting plan has sites that are performing poorly, an excess of TIME_WAIT connections may be contributing to the poor performance.
This article covers how to check and mitigate too many TIME_WAIT connections.
Related Article
Checking TIME_WAIT Connections
NOTE: While there are many traffic-related reasons why a website can have poor performance, at least one very easy test is to see if the poor performance is due to too many network connections stuck in TIME_WAIT.
TIP: If the server cannot immediately respond to a GET request due to sluggish MySQL performance, maxed-out IO, throttled CPU, or other resource usage-related issues, then the site visitor's connection status will change from ESTABLISHED to TIME_WAIT. An easy way to figure this out is to use the netstat command and count the number of TIME_WAIT connections.
- SSH into the server as the root user
- Run
netstat -nat | awk '{print $6}' | sort | uniq -c | sort -n
EXAMPLE: In this example, there are way too many TIME_WAIT connections. It is OK for TIME_WAIT to be 4 times the number of ESTABLISHED connections, but any significant amount higher than this will likely result in sluggish server performance.
1 Foreign
3 CLOSING
8 FIN_WAIT2
18 FIN_WAIT1
24 CLOSE_WAIT
25 LAST_ACK
41 LISTEN
84 SYN_RECV
241 ESTABLISHED
4668 TIME_WAIT
Resolving TIME_WAIT Connections
NOTE: If the output is similar to the above example follow these steps to mitigate this.
- Log Into Root WHM
- Navigate to the Apache Configuration section
- Click Global Settings
- Locate the Keep-Alive setting and select the ON radio button
- Click Save
TIP: After this feature is enabled, there should be an immediate reduction in TIME_WAIT connections, and within a couple of minutes the number of TIME_WAIT should be at an acceptable 1/4th ratio to ESTABLISHED connections.
Comments
0 comments
Article is closed for comments.