Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6147623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:08:03+00:00 2026-05-23T19:08:03+00:00

I am using node-mysql module ( https://github.com/felixge/node-mysql ) OR ( http://utahjs.com/2010/09/22/nodejs-and-mysql-introduction/ ) . Is

  • 0

I am using node-mysql module (https://github.com/felixge/node-mysql) OR (http://utahjs.com/2010/09/22/nodejs-and-mysql-introduction/) .

Is this API handling connection pooling as well?

I mean with every user request I am calling Client.connect() to query the MySQL and to release the connection: Client.end().

Is this the right way, or should I connect/disconnect only once in a code.

I am learning from this document: https://github.com/felixge/node-mysql/blob/master/Readme.md

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T19:08:03+00:00Added an answer on May 23, 2026 at 7:08 pm

    Update: Feb 2013 – pool support has been added to node-mysql, see docs

    Example using built-in pool:

    var pool = require('mysql').createPool(opts);
    
    pool.getConnection(function(err, conn) {
      conn.query('select 1+1', function(err, res) {
        conn.release();
      });
    });
    

    Pre 2013 solutions:

    You can use node-pool or mysql-pool or use your own simple round-robin pool

    function Pool(num_conns)
    {
        this.pool = [];
        for(var i=0; i < num_conns; ++i)
            this.pool.push(createConnection()); // your new Client + auth
        this.last = 0;
    }
    
    Pool.prototype.get = function()
    {
        var cli = this.pool[this.last];
        this.last++;
        if (this.last == this.pool.length) // cyclic increment
           this.last = 0;
        return cli;
    }
    

    now you can hope to have all queries callbacks to execute in 1 second:

    var p = new Pool(16);
    for (var i=0; i < 10; ++i)
    {
        p.get().query('select sleep(1)', function() { console.log('ready'); } ); // server blocks for 1 second
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using a forum with several topics and node comments module to add comment
I am using node-mysql driver for a node.js app. Instead of having to set-up
I am building an app on node.js using express, and node-mysql driver. There is
I have a tree structure in MySQL using a parent_id field for each node.
I'm attempting to check for the existence of a node using the following .NET
Anyone know how to get the position of a node using XPath? Say I
Using C# How do you remove a specific node from an XMLDocument using XPATH?
I'm using XPath to locate a node (or something close to it) in a
I need to locate the node within an xml file by its value using
Anybody out there using BGL for large production servers? How many node does your

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.