Number of Windows sockets Max connections

Source: Internet
Author: User

When the Socket is programmed, the maximum number of TCP connections a single machine can establish is affected by the operating system.

The number of TCP connections for a single machine under Windows is affected by multiple parameters:

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 = MB (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.

Reference: Typical configuration for IBM WebSphere Voice server under Windows Server 2003

MaxUserPort = 65534 (Decimal)

MaxHashTableSize = 65536 (Decimal)

MaxFreeTcbs = 16000 (Decimal)

Here MaxHashTableSize is configured to be 4 times times larger than MaxFreeTcbs, which can greatly increase the speed of TCP setup.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.