Maximum number of TCP connections for a single machine under Windows
Referenced from: http://www.cnblogs.com/eaglet/archive/2010/09/21/1832233.html
When doing socket programming, we often ask how many TCP connections can be built on a single machine, and this article describes how to adjust the system parameters to adjust the maximum number of TCP connections for a single machine.
The number of TCP connections for a single machine under Windows is determined by several parameters, as described below:
Maximum number of TCP connections
[HKEY_LOCAL_MACHINE \system \CurrentControlSet \services \TCPIP \parameters]
TcpNumConnections = 0x00fffffe (Default = 16,777,214)
The above registry information configures the maximum allowable number of TCP connections for a single machine, which defaults to 16M. This value appears to be large, which is not the only condition that limits the maximum number of connections, and other conditions limit the maximum number of connections to a TCP connection.
Maximum number of dynamic ports
When a TCP client and server are connected, the client must assign a dynamic port, which by default allocates a range of 1024-5000, which means that by default, the client can initiate up to 3,977 socket connections at a time. We can modify the following registry to adjust the range of this dynamic port
[HKEY_LOCAL_MACHINE \system \CurrentControlSet \services \TCPIP \parameters]
MaxUserPort = (Default =, Max = 65534)
Max TCB Quantity
The system assigns a TCP control block to each TCP connection (TCP-control block or TCB), which is used to cache some parameters of a TCP connection, and each TCB needs to allocate 0.5 KB of Pagepool and 0.5KB Non-pagepool, saying that Each TCP connection consumes 1KB of system memory.
The maximum number of TCB for the system is determined by the following registry setting
[HKEY_LOCAL_MACHINE \system \CurrentControlSet \services \TCPIP \parameters]
MaxFreeTcbs = (Default = RAM dependent, but usual Pro = $, srv=2000)
Non-server version, the default value for MaxFreeTcbs is (64M + physical Memory)
The Server version, which has a default value of 2000.
In other words, by default, the Server version can establish and maintain up to 2000 TCP connections at a time.
Max TCB Hash Table number
The TCB is managed by a hash table, and the following registry setting determines the size of the hash table
HKEY_LOCAL_MACHINE \system \CurrentControlSet \services \TCPIP \parameters]
MaxHashTableSize = (Default = +, Range = 64-65536)
This value indicates the amount of pagepool memory allocated, that is, if MaxFreeTcbs = 1000, the amount of memory Pagepool is 500KB
Then the maxhashtablesize should be greater than 500. The larger the number, the higher the redundancy of the hash table, and the less time it takes to allocate and find the TCP connection. This value must be a power of 2 and a maximum of 65536.
Typical configurations for IBM WebSphere Voice server under Windows Server 2003
This is a typical configuration of the IBM WebSphere Voice Server, and you can make a reference. See the original
IBM Web Sphere Voice Server Configuration
- MaxUserPort = 65534 (Decimal)
- MaxHashTableSize = 65536 (Decimal)
- MaxFreeTcbs = 16000 (Decimal)
Here we can see that the maxhashtablesize is configured to be 4 times times larger than the MAXFREETCBS, which can greatly increase the speed of TCP setup.
Maximum number of TCP connections for a single machine under Windows