Too many connections” error
max_connections
By default 151 is the maximum permitted number of simultaneous client connections in MySQL 5.5.
If you reach the limit of max_connections you will get the “Too many connections” error when you to try to connect to your MySQL server. This means all available connections are in use by other clients.
MySQL permits one extra connection on top of the max_connections limit
which is reserved for the database user having SUPER privilege in order to diagnose connection problems. Normally the administrator user has this SUPER privilege. You should avoid granting SUPER privilege to app users.
It depends on the amount of RAM available and memory usage for each connection.
Increasing max_connections value increases the number of file descriptors that mysqld requires.
Note: there is no hard limit to setting up maximum max_connections value.
So, you have to choose max_connections wisely as per your workload, number of simultaneous connections to MySQL server etc. In general, allowing too high of a max_connections value is not recommended because in case of some locking conditions or slowdowns if all those connections running huge contention issue may raise.
In the case of active connections using temporary/memory tables, memory usage can go even higher.
On systems with small RAM or with a hard number of connections control on the application side,
we can use small max_connections values like 100-300. Systems with 16G RAM or higher max_connections=1000 is a good idea,
and per-connection buffer should have good/default values while on some systems we can see up to 8k max connections, but such systems usually became down in case of load spikes.
MySQL uses one thread per client connection and many active threads are performance killer.(性能杀手: 降低性能)
per thread per client connection
太多的活跃线程就是性能杀手。
网友评论