This article shows how to improve Server / System performance by changing the TIME_WAIT and FILE DESCRIPTOR limit in Windows 2003, XP and Vista.
Few months back, all of sudden there was a requirement from the server side team, saying that one of our server and collector-writer service is behaving sluggish as they are encountering unexpected massive volume of data and they need a fix for it very badly.
This article consist of two parts (1) Changing TIME_WAIT Limit and (2) Changing FILE DESCRIPTOR Limit.
NETSTAT is a command which displays protocol statistics and current TCP/IP network connections. If you run a netstat -a command you will see different connection states like ESTABLISHED, LISTENING, CLOSE_WAIT... TIME_WAIT. TIME_WAIT state is the state in which a connection is waiting for the specified period of time (default is 240 seconds i.e 4 minutes) before getting closed and if there are huge number of connections in TIME_WAIT state on your Server/ System then it could limit the maximum number of connections and and reducing this TIME_WAIT default period will increase the maximum connection limit of your system. To reduce/modify the TIME_WAIT default period you need to modify the value of 'TcpTimedWaitDelay' Registry key. The value of 'TcpTimedWaitDelay' determines the length of time that a connection will stay in the TIME_WAIT state before being closed. Follow the steps given below to edit 'TcpTimedWaitDelay' settings.
Step1: Go to the Registry Key-- HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters Step2: Create a new DWORD ( REG_DWORD ) value, or modify the existing value called 'TcpTimedWaitDelay' if it's already there. Step3: Set the Value between 30-300 seconds (decimal). Step4: Exit your registry, and restart the System.
FILE DESCRIPTOR Limit is the upper limit to the number of files that a program can open simultaneously. Windows has a hard upper file descriptor limit of 512 at the 'stdio level' i.e. any program can open a limited number of 512 files simultaneously at stdio level, but using the C runtime library Windows hard upper limit for file descriptors can be extended to 2048 i.e. any program can open upto 2048 number of files simultaneously using the C runtime 'setmaxstdio' call.
To change the File Descriptor's Limit, Application can use 'setmaxstdio' CRT call to change the maximum value for the number of files that might be opened simultaneously. The attached application FileDescriptor.exe uses the 'setmaxstdio' call.
The application FileDescriptor.exe has five options:
For more details look at the Source Code.
If your application requires to open more then 2048 files simultaneously then your application should use the native Win32 API calls (E.g. CreateFile) instead of C runtime library.
Initial Version 1.0.
| You must Sign In to use this message board. | |||||
|
|||||