|
1, MySQL database system to allow the maximum number of connections max_connections. This parameter can be set. If not set, the default is 100. The maximum is 16384.
2, the current database connection threads threads_connected. This is a dynamic change.
View max_connections, max_connections approach see below.
If when threads_connected == max_connections, the database system can not provide more connections, and then, if the program would like to create a new connection threads, the database system will be rejected if the program did not do much error handling, there will be similar strong altar of error messages.
Because creating and destroying database connection resources, will consume system. And in order to avoid too many open simultaneously at the same time the connection thread, now generally use the so-called programming database connection pool technology.
But the database connection pool, and can not avoid procedural errors caused the connection resource depletion.
This usually occurs in the program failed to release the database connection resources or other causes database connection resources can not be released, but it is estimated that this low intensity system altar programming errors do not occur.
Easy way to check the error is in strong altar refresh the page constantly monitors the changes threads_connected. If max_connections large enough, increasing the value and threads_connected even reach max_connections, so, you should check the program. Of course, if the maximum number of threads connecting a database connection pool, threads_connected growth to the database connection pool use, no longer increase.
Strong altar from the situation of error, the more likely is the database system could not be properly configured. Ask the following piece of advice. for reference
Let your engineers to MySQL's maximum allowable number of connections from the default of 100 tune into 32000. This is not the old problem of excessive connected.
View max_connections
Enter MySQL, use the command:
show variables
View database maximum number of connections to the values:
max_connections
View threads_connected
Enter MySQL, use the command:
show status
View the current activity variable values connecting thread:
threads_connected
Setting max_connections
Approach is set in the my.cnf file, add the following last red line:
[Mysqld]
port = 3306
# Socket = MySQL
skip-locking
set-variable = key_buffer = 16K
set-variable = max_allowed_packet = 1M
set-variable = thread_stack = 64K
set-variable = table_cache = 4
set-variable = sort_buffer = 64K
set-variable = net_buffer_length = 2K
set-variable = max_connections = 32000
After modification, you can restart the MySQL. Of course, in order to ensure the settings are correct, we should look max_connections.
note:
1, although the writing here 32,000. But the maximum number of connections the actual MySQL server allows 16384;
2, in addition to max_connections, the above-mentioned other configuration should be based on their need to configure your system, not rigidly stick to;
3, add the maximum allowable number of connections to the system consumes little increase.
4, if you use the my.ini for mysql configuration file settings similar, but set the format to make some modifications |
|
|
|