Windows Socket Max connections

Source: Internet
Author: User
Document directory
  • Maximum number of TCP connections
  • Maximum number of dynamic ports
  • Maximum TCB count
  • Maximum number of TCB hash tables

During socket programming, the maximum number of TCP connections that a single machine can establish is affected by the operating system.

The number of TCP connections on a single machine in 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 preceding Registry Information configures the maximum number of TCP connections allowed for a single machine. The default value is 16 Mb. This value seems to be very large. This is not the only condition for limiting the maximum number of connections. There are other conditions that will limit the maximum number of connections to the TCP connection.

Maximum number of dynamic ports

When the tcp client is connected to the server, the client must allocate a dynamic port. By default, the allocation range of this dynamic port is 1024-5000, that is, by default, the client can initiate up to 3977 socket connections at the same time. Modify the following registry to adjust the range of the dynamic port.

[HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ Tcpip \ Parameters] maxuserport = 5000 (default = 5000, max = 65534)

Maximum TCB count

The system assigns a TCP Control Block or TCB to each TCP connection. This control block is used to cache some TCP connection parameters, each TCB needs to allocate a 0.5 kb pagepool and a kb non-pagepool. That is to say, each TCP connection occupies 1 kb of system memory.

The maximum number of TCBs in the system is determined by the following registry settings:

[HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ Tcpip \ Parameters] maxfreetcbs = 2000 (default = Ram dependent, but usual pro = 1000, SRV = 2000)

For non-Server versions, the default value of maxfreetcbs is 1000 (physical memory larger than 64 MB)

Server version. The default value is 2000.

That is to say, by default, up to 2000 TCP connections can be established and maintained at the same time in the server version.

Maximum number of TCB hash tables

TCB is managed by hash table. The following registry settings determine the size of the hash table.

HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ Tcpip \ Parameters] maxhashtablesize = 512 (default = 512, range = 64-65536)

This value indicates the number of pagepool memory allocated. That is to say, if maxfreetcbs = 1000, the size of pagepool memory is kb.

The maxhashtablesize must be greater than 500. The larger the number, the higher the redundancy of the hash table, and the smaller the number of TCP connections allocated and queried each time. The value must be a power of 2 and the maximum value is 65536.

Reference: typical configurations of IBM WebSphere voice server in Windows Server 2003

Maxuserport = 65534 (decimal)

Maxhashtablesize = 65536 (decimal)

Maxfreetcbs = 16000 (decimal)

Maxhashtablesize is configured to be 4 times greater than maxfreetcbs, which can greatly increase the speed of TCP establishment.

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.