4

I have 2 servers, both running RHEL 6, one for Apache 2.2 and one for memcached (memcached-1.4.4-3).

I noticed an increase in the number of TIME_WAIT connections on the Apache server

netstat -n | grep 11211  | awk '{print $6}' | sort |  uniq -c
      1 ESTABLISHED
    807 TIME_WAIT

and still the number increases.

  • Does TIME_WAIT mean it is still used ?
  • Is increasing the number will affect the server performance?
  • How can I get rid of them ?
Ladadadada
  • 25,847
  • 7
  • 57
  • 90
user161834
  • 311
  • 3
  • 6
  • 8

1 Answers1

4

Connections in the TIME_WAIT state can cause a problem, but only when you get to about 30,000 of them.

Each one of these connections is holding open the local IP address and port in case any more packets from the earlier, finished connection were delayed and come through after the connection has been closed. This is a design feature of TCP.

If you have too may of them, new connections cannot be opened until some of the connections in the TIME_WAIT state expire. The symptoms you might see at the front end are slower-than-usual HTTP requests, particularly when the site is heavily loaded. (But these symptoms can have many, many different causes so don't immediately jump to this conclusion.)

I've only ever once run into this problem and it was due to a misbehaving script on some servers that was opening a new connection to the database for every query rather than holding open a single connection and running multiple queries over it. It's not a common problem.

Ladadadada
  • 25,847
  • 7
  • 57
  • 90