Forwarding + likes = support
Baidu Search: Xiao Qiang test brand
AC Group: 522720170
Phenomenon
Log logs frequently appear error:too many connections such an error.
Analysis
See Such an error, we probably also know why, is nothing more than the connection is full, or there is a problem in the code to cause unreasonable close connection. In the performance testing of Xiao Qiang, I always insist on the transfer of thought-led, knowledge supplemented. Why, because everyone is a smart person, thought has how to do that everyone has a way for everyone to progress the fastest.
Well, a bit more nonsense, back to the point, why I will mention the idea of the above. Because only you have this idea to be a clerk! Many times we want to be a clerk but no idea! So learning is a train of thought, not knowledge at all!
We know the possible causes to be followed up one by one, the approximate steps are as follows:
1, see the number of connections. MySQL configuration of the maximum number of connections is 100, but the application side of the most 30~40 bar, should not appear this problem, so pass off
2, the rest is the code, focus on the SQL section, put to establish a connection and release the connection where to troubleshoot
Source:
Pool.getconnection (function (err, connection) {
if (err) throw err;
Connection.query (SQL, function (err, rows, fields) {
if (err) {
return Cosole.error (ERR);
}
CB (rows);
});
Release this connection
Connection.release ();
Can you see what the problem is? Well, I guess, can't see ~ haha
In fact, a little bit of code to understand the children's shoes should be able to see that the release of the connection statement place a bit wrong.
After modification:
Pool.getconnection (function (err, connection) {
if (err) throw err;
Connection.query (SQL, function (err, rows, fields) {
Release connection
Connection.release ();
if (err) {
return Cosole.error (ERR);
}
CB (rows);
3, after the revision verification, everything, Amitabha!
MySQL database too many connections error troubleshooting