mysql connection intermittent disconnection solution

When doing performance testing, if the system page to be tested is very simple and has good performance, it will cause the pressure machine to have insufficient tcp links and cause the following errors:

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\tcpip\Parameters\TcpTimedWaitDelay to 30
and HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\tcpip\Parameters\MaxUserPort to 65534
and rebooting the machine
See the readme.doc file for more information

The most introduced through Baidu search is to modify the two values ​​of TimedWaitDelay and MaxUserPort. Among them, the relatively small point of modifying TimedWaitDelay can be determined according to the actual situation.

At the same time, modify the value of MaxUserPort to a larger value, but after modifying and restarting the machine, the problem still exists. After checking the information from various parties, modify some registry:

[HKEY_LOCAL_MACHINE \System \CurrentControlSet \Services \Tcpip \Parameters] 
TcpNumConnections = 0x00fffffe (Default = 16,777,214) 
The above registry information configures the maximum number of TCP connections allowed for a single machine, the default is 16M. This value may seem large, but this is not the only condition that limits the maximum number of connections, there are other conditions that limit the maximum number of connections to TCP connections. 
Maximum number of dynamic ports  When a
TCP client connects to a server, the client must allocate a dynamic port. By default, the allocation range of this dynamic port is 1024-5000, which means that by default, the client can initiate a maximum of 3977 Sockets at the same time. connect. We can modify the following registry to adjust the range of this dynamic port 
[HKEY_LOCAL_MACHINE \System \CurrentControlSet \Services \Tcpip \Parameters] 
MaxUserPort = 5000 (Default = 5000, Max = 65534) 

Maximum number of TCBs 

The system allocates a TCP for each TCP connection Control block (TCP control block or TCB), this control block is used to cache some parameters of TCP connection, each TCB needs to allocate 0.5KB pagepool and 0.5KB Non-pagepool, that is to say, each TCP connection will occupy 1KB system memory. 

The maximum number of TCBs for 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 version, the default value of MaxFreeTcbs is 1000 (more than 64M physical memory) For 

Server version, the default value for this is 2000. 

That is, by default, the Server version can establish and maintain up to 2000 TCP connections at the same time. 
The maximum number of TCB Hash tables 

TCB is managed by Hash table, the following registry settings determine the size of this Hash table 

HKEY_LOCAL_MACHINE \System \CurrentControlSet \services \Tcpip \Parameters] 
MaxHashTableSize = 512 (Default = 512, Range = 64-65536 ) 

This value indicates the amount of allocated pagepool memory, that is, if MaxFreeTcbs = 1000, then the amount of pagepool memory is 500KB 

, then MaxHashTableSize should be greater than 500. The larger the number, the more redundant the Hash table is, and the less time it takes to allocate and find a TCP connection each time. This value must be a power of 2, with a maximum of 65536. 

    MaxUserPort = 65534 (Decimal) 
    MaxHashTableSize = 65536 (Decimal) 
    MaxFreeTcbs = 16000 (Decimal) 

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

 Copyright statement: Some materials in this blog are collected from the Internet. If there is any infringement, please contact me to delete it.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325330113&siteId=291194637