Server: Windows2000 Server + iis5.0 + PhP ISAPI + MySql
I developed a web site using PHP + MySQL, which has a high access volume.
However, after running normally for more than a week, frequent occurrences of can't connect
To MySQL server on 'localhost' (10048) error.
The statistical data is as follows:
10,594 Failed Connections
Total connections per hour: 885.37
%
15.91%
We can see that the connection failure rate is very high. It should be emphasized that there was no such high error rate in the same number of links a week ago.
Cause Analysis: using the fport tool, you will find that someone is exhausting your database connection. Obviously, their features are: dozens of connections come from the same IP address, all of which are time-wait.
Solution, 1. We recommend that you modify the maximum number of connections, or change the mysql_connect () method to the mysql_pconnect () method,
2. Block these IP addresses. If an IP address is greater than 3, It is abnormal.
3. Fix the problem and modify the site program. Refreshing is strictly prohibited!
Modify the number of links:
This error is related to a registry key value tcptimedwaitdelay. Reduce windows
The tcptimedwaitdelay time can solve this problem. The default value is 240 (this value is also not set ). To set this option, go to the Registry as follows: [HKEY_LOCAL_MACHINE]
[System] [CurrentControlSet] [services] [TCPIP] [parameters]
[Tcptimedwaitdelay] If the registry does not contain the tcptimedwaitdelay project, add the project and set it to the double-byte (DWORD) type. Set the value to 30.
~ Between 60.
Tcptimedwaitdelay Description: determines the TCP/IP
The time required to release closed connections and reuse their resources. The time interval between closing and releasing is called time_wait.
Status or two times the maximum segment lifecycle (2msl) status. During this period, the cost of re-opening a connection to the client and server is less than creating a new connection. Reduce the value of this entry to allow TCP/IP
Release closed connections faster and provide more resources for new connections. If the running application needs to be quickly released and created
If there are many connections, resulting in low throughput, adjust this parameter. How to view or set: Use the Regedit command to access
HKEY_LOCAL_MACHINE/system/CurrentControlSet/services/TCPIP/parameters
The registry subkey and create a new REG_DWORD value named tcptimedwaitdelay. Set this value to decimal 30, which is hexadecimal
0 × 0000001e. This value sets the wait time to 30 seconds. Stop and restart the system. Default Value: 0xf0, which sets the wait time to 240 seconds (4 minutes ). Recommended Value: Minimum value:
0 × 1E, which sets the wait time to 30 seconds.
Http://adamghost.com/2008/11/mysql-10055-%E9%94%99%E8%AF%AF%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88? Jdfwkey = gkden3