Skip to content

Open new connections to keep pool "warm" #1229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
acorbi opened this issue Sep 29, 2015 · 1 comment
Closed

Open new connections to keep pool "warm" #1229

acorbi opened this issue Sep 29, 2015 · 1 comment
Assignees
Labels

Comments

@acorbi
Copy link

acorbi commented Sep 29, 2015

Here is my scenario:

On a multi-instance nodejs server application I am expecting high traffic peaks in which it would be beneficial to have a Connection Pool with many open and free connections waiting for the request bursts to come. By doing that, the requests would be served instantaneously without having the CPU overhead of opening them all of a sudden. In my scenario, the connectionLimit is rather high ( ~400 per node instance ) and opening that big number of connections at once can cause high CPU peaks on the database instance.

On the Pool module https://github.com/felixge/node-mysql/blob/master/lib/Pool.js#L22-L70 I can see the getConnection method which first checks if free/released connections are available and acquires them before creating new ones, but what I am actually interested in is to create a max of connectionLimit number of free connections to be acquired by threads running actual queries on the mentioned high traffic situations.

My approach:

On acorbi@f7e10e1 you can see my approach. In a nutshell, it consists on adding a new function to the Pool module which allows to create those connections (as long as the limit allows it) without checking first if there are free connections available.

After calling getNewConnection method I am releasing the connection by calling connection.release():

this.getNewConnection(function(err, connection) {
     connection.release();
});

My questions:

Does my approach actually make sense? Would you suggest other alternatives to achieve this warm-up without tweaking the actual node-mysql implementation? In case you "like" this feature, would you suggest any other "more elegant" way of implementing this. Would you be interested in a PR?

Greetings

@dougwilson
Copy link
Member

Closing in favor of the discussion in #1232

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants