Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


January 2002

The TIME_WAIT State's Effect on IIS Performance

RSS
Subscribe to Windows Web Solutions | See More Registry Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

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.)

End of Article



Reader Comments
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.


Anonymous User October 29, 2004 (Article Rating: )


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 November 11, 2004 (Article Rating: )


You must log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

How can I stop and start services from the command line?

...

PsExec

This freeware utility lets you execute processes on a remote system and redirect output to the local system. ...


Related Events Delivering Reliable and Effective Web-Based Applications

Making Web Application Perform Better: What to Watch, How to Watch It, and How to Fix It

Check out our list of Free Email Newsletters!

IIS and Web Administration eBooks Keeping Your Business Safe from Attack: Monitoring and Managing Your Network Security

Related IIS and Web Administration Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing