Subscribe to Windows IT Pro

 

Get Newsletters

  • Get the Latest News
  • Product Updates
  • Helpful Tricks
  • Productivity Tips

Subscribe Now!

December 20, 2001 12:00 AM

The TIME_WAIT State's Effect on IIS Performance

Windows IT Pro
InstantDoc ID #23276
Rating: (6)

My IIS 5.0 server is usually under a large load, and performance slows periodically. While investigating the problem, I've discovered more than 1000 TCP ports in the TIME_WAIT state. Is this state typical on an active server, and could it be affecting performance?

The TIME_WAIT state is typical, but it can also affect performance. You might want to adjust the amount of time your IIS machine keeps a TCP/IP session open after the client has disconnected. After a connection is closed, the server port goes into a TIME_WAIT state when the client sends the server a FIN packet. By default, the server then keeps the connection alive for 4 minutes. (Internet Engineering Task Force—IETF—Request for Comments—RFC—793 provides the rationale for keeping the connection alive this long.) As long as the server port is in TIME_ WAIT state, no other connections can be made to the port. This default time is protection against delayed network communication from an old session intermingling with communication from a new session and resulting in unpredictable consequences.

Network traffic on today's Internet and intranets is unlikely to have a 4-minute latency. Consequently, you can usually decrease the TIME_WAIT interval to 1 minute or less. This change will cause your server to recycle connections almost four times faster than the default configuration, resulting in more efficient use of your server's resources. You can use the Netstat (netstat.exe) utility to determine how many ports are in the TIME_WAIT state. (For more information about TCP connections and the Netstat utility, see the Microsoft article "TCP Connection States and Netstat Output" at http://support.microsoft.com/support/kb/articles/q137/9/84.asp.)

The setting you need to adjust to change the TIME_WAIT interval doesn't exist by default. You must add the Tcp TimedWaitDelay REG_DWORD value to the HKEY_LOCAL_MACHINE\ SYSTEM\CurrentControlSet\Services\ Tcpip\Parameters registry subkey. Then, you set the delay to the number of seconds (in decimal form):

Value Type: REG_DWORD--
  Time in seconds
Valid Range: 30­300 (decimal)
Default: 0xF0 (240 decimal)

Of course, before you make any changes to the registry, be sure you have a good recovery system in place. For more information about this registry change, see the Microsoft article "TCP/IP and NBT Configuration Parameters for Windows" (http://support.microsoft.com/support/kb/articles/q120/6/42.asp) and the Windows Registry Guide Web site (http://www.winguides.com/registry/display.php/878).

Another factor that can affect performance is that you might be running low on ephemeral ports—ports used to create connections to the client computers from the server and between COM server objects. By default, these ports range from 1024 to 5000, and if you run out of them, connection problems can occur. As the Microsoft article "Unable to Connect from TCP Ports Above 5000" (http://support.microsoft.com/support/kb/articles/q196/2/71.asp) states, you can increase the number of ports available to 65,535. Each port uses 2KB to 4KB of memory, so be certain you have ample RAM to support the number of connections you intend to use. (Each connection requires at least one port.)

Related Content:

ARTICLE TOOLS

Comments
  • Alon Leibovich
    2 years ago
    Dec 07, 2010

    Hi,
    I have situation and I would like to find out if it is a problem or not.

    A .NET client application makes 2000 short simultaneous or iterative connections to a web service.
    The client is using a simple SoapHttpClientProtocol.
    The Keep-Alive setting on the IIS is set to False (There is a reason for this)
    The entire process takes 15 sec.

    Afterwards when I'm checking the open tcp connection on the IIS (by using netstat) I can see 2000 tcp:80 connections in status TIME_WAIT.

    Is this a problem?
    Will it prevent additional web requests until these are freed up?

  • Anonymous User
    8 years ago
    Nov 11, 2004

    I have an issue where I need to connect through port 27001 and I am getting a TIME_WAIT when running NETSTAT -a on the client pc. We are unable to get the software to read the license files on the server and am wondering when it states TIME_WAIT is is blocking that port in anyway?? I get the feeling it means there is a connection but in reality there hasnt been one? Any info is greatly appreciated.

  • Anonymous User
    8 years ago
    Oct 29, 2004

    That socket (TCP Connection Endpoint) cannot be re-established until TIME_WAIT ends -- which means that connections can still be made to that port. They just can't be made from the same remote IP and remote port addresses that are currently in TIME_WAIT. That port will be able to accept other connections from other addresses/ports.

You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

White Papers

Get your Windows 7 deployment off to the right start by implementing PC lockdown. A locked-down environment is easier and cheaper to support since users are less likely to make unnecessary changes to the core system configuration - read more here!

Essential Guides

Is your iSCSI "lossy"? The reality is that most off-the-shelf Ethernet hardware deployed for iSCSI can lose packets, resulting in slow performance or application downtime. Learn how to assess your current iSCSI infrastructure and engineer an advanced iSCSI SAN infrastructure.

Web Seminars

What's the best way to keep your network safe from malware? In this web seminar, security expert Greg Shields suggests an alternative method to the traditional blacklisting approach that is common with anti-virus and anti-malware solutions.

eLearning Series

We bring the experts direct to you to share their real-world perspective and expertise. During each event, three sessions stream in real time, so you can learn, ask questions, and get solutions.
Upcoming event: Getting the Most with Exchange 2010 with Paul Robichaux

Subscribe to Windows IT Pro!

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.