MySQL database too many connections error troubleshooting

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.