Skip to content

Increasing number of connections to mysql #712

@nareshbhatia

Description

@nareshbhatia

I am trying to performance tune a small sample app. I started with 100 connections and hitting the node server as fast as possible. I got a throughput of ~1200 request/second. Now I tried to increase the number of db connections to 400 (by setting the connectionLimit). However, when I do this and start hitting the server hard, I get the following error:

ER_CON_COUNT_ERROR: Too many connections

How can I increase the number of connections? I don't think this is an issue on the MySQL end because I am easily able to run the same test using a Java server on the same MySQL instance.

Here's my node.js code:

var Mysql = require('mysql');

var pool = Mysql.createPool({
    host: 'localhost',
    user: 'bfoms_javaee',
    password: 'bfoms_javaee',
    database: 'bfoms_javaee',
    connectionLimit: 400
});

exports.findAll = function(req, res) {

    pool.getConnection(function(err, connection) {
        if (err) throw err;

        connection.query('SELECT * FROM orders WHERE symbol="GOOG"', function(err, rows, fields) {
            if (err) throw err;

            res.send(rows);
        });

        connection.release();
    });
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions