Hi,
Thanks for posting in Q&A platform.
Server is usually fixed to listen on a local port, waiting for a connection request from client. Regardless of address reuse, the local listening port is exclusive even if there are multiple IP on the server side, so only remote IP (i.e. client IP) and remote port (client port) in the server-side TCP connection 4 tuple are variable, so the maximum TCP connection is the number of client IP × the number of client ports, IPv4, regardless of IP address classification and other factors, the maximum number of TCP connections is about 2 of the 32 times (IP number) ×2 of the 16 times (port number), that is, the maximum number of server side stand-alone TCP connections is about 2 of the 48 times.
The above is given the theoretical maximum number of single-machine connections, in the actual environment, by machine resources, operating system and other limitations, especially the sever side, its maximum concurrent tcp connection number is far from reaching the theoretical upper limit. Maximum TCP connections depends on several factors of our Windows server, it's hard to say an accurate number.
----------
If you are using a high number of TCP connections, particularly with a high connect/disconnect rate, you may exhaust the number of available ports as they may all be in the TIME_WAIT state.
There are two actions that can prevent this:
1. Increasing the number of available (ephemeral) ports.
2. Reducing the TIME_WAIT timeout period.
----------
1. Increasing the number of available (ephemeral) ports.
By default, Windows only allocates ephemeral ports in the range 1024 through 4999.
To increase the upper range of ephemeral ports that are dynamically allocated to client TCP/IP socket connections perform the following. You should first save a backup of the registry.
Start the Registry Editor.
Browse to, and then select the following key in the registry:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
Create a new DWORD value, or modify the existing value of MaxUserPort to increase the number of ephemeral ports that can by dynamically allocated to clients:
Value name: MaxUserPorts
Value data: <Enter a decimal value between 5000 and 65534>
Save the changes and close the Registry Editor.
Please note: You must restart your computer for this change to take effect.
----------
2. Reducing the TIME_WAIT Timeout Period
This setting determines the length of time that a connection will stay in the TIME_WAIT state before being closed. The default is 240 seconds which on a busy server will limit the maximum connections to around 200/sec. Reducing this setting will increase the maximum connection limit.
Start the Registry Editor.
Browse to, and then select the following key in the registry:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
Create a new DWORD value, or modify the existing value of TcpTimedWaitDelay to alter the TIME_WAIT duration:
Value name: TcpTimedWaitDelay
Value data: <Enter a decimal value between 30 and 300 seconds>(I would suggest you configure this value to 30)
Save the changes and close the Registry Editor.
Please note: You must restart your computer for this change to take effect.
Hope this will help you.
Best Regards,
Sunny
----------
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.