8

Our server is overloaded with TCP/IP sessions, we have 1200 - 1500 of them. Most of them are hanging in TIME_OUT state. It turns out that a connection in TIME_OUT state occupies a socket until 60 second time-out is elapsed.

The problem is that the server gets unresponsive and many clients are not getting served.

I have made a simple test: download an XML file from the server with Internet Explorer 8.0 The download finishes in a fraction of second. But then I see that the TCP/IP connection is hanging in TIME_OUT state for 60 seconds.

Is there any way to get rid of TIME_OUT waiting or make it less to free the socket for new connections?

I understand why TCP/IP connection enters TIME_OUT state, but I don't understand why Internet Explorer does not close the connection after the XML file download is over.

The details.

Our server runs web service written in Perl (mod-perl). The service provides weather data to clients. Client is a Flash appication (actually Flash ActiveX control embedded in Windows application).

OS: Ubuntu

Apache "Keep Alive" option is set to 0

4
  • If you understand why it enters the TIME_OUT state, then you must understand why this is necessary to prevent other attacks and problems. You can reduce this timeout, but there are other consequences to doing that.
    – davr
    Apr 5, 2010 at 15:43
  • Syntax is KeepAlive on|off. KeepAlive 0 is Apache 1.1 syntax; I assume you are not using that.
    – mark4o
    Apr 5, 2010 at 16:48
  • 1500 T/O session don't make your system unresponsive. There's another reason.
    – poige
    Sep 16, 2011 at 1:50
  • Are connections going through a cheap router?
    – LatinSuD
    Jun 12, 2014 at 9:36

3 Answers 3

7

This is a setting in your TCP stack. Since we don't know what platform you're on we can't say exactly what it's called and how to change it.

UPDATE

So you're using Ubuntu. You can use sysctl to reduce the net.inet.tcp.msl value to half the desired TIME_WAIT duration (in milliseconds -- see man -S 4 tcp), e.g. sysctl net.inet.tcp.msl=2500. Beware of the implications of doing so with respect to wandering packets that may arrive after the TIME_WAIT period elapses.

2
  • Our server runs Ubuntu, I have updated the details
    – par
    Apr 5, 2010 at 15:47
  • «1200 - 1500 of them» won't hurn even calculator, so it's not the reason to tune msl
    – poige
    Sep 16, 2011 at 1:49
1

I assume you mean TIME_WAIT. The peer that initiates the active close is the one that enters TIME_WAIT (see state transition diagram here) so if you can have your client close the connection then you'll move the TIME_WAIT off to the client. See this answer for more details and a link to a good article about TIME_WAIT problems and how to solve them.

Another alternative, if you cant have the client issue the active close, is to reset the connection by setting linger to false before closing it. This causes an RST to be sent rather than FIN.

2
  • Oh, thank you very much! But how can I control TCP/IP connection when the user loads an XML file with Internet Explorer?
    – par
    Apr 6, 2010 at 8:07
  • TIME_WAIT is normal and unless your server performance is suffering because of it it's not something I'd worry too much about. When the socket is in TIME_WAIT it takes up some resources but it doesn't mean that the connection is still open or that the server is still processing it. Apr 6, 2010 at 8:21
0

The server being unresponsive likely has nothing to do with the number of connections in TIME_WAIT state. It's not clear what you mean by "occupies a socket" -- the server should long since has closed the socket at that point. The system should be able to handle tens of thousands of connections in TIME_WAIT state.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .