1

I'm trying to connect Nodejs to PostgreSQL database, for that I'm using node-postgres.

var pool = new Pool({
    user: username,
    password: password,
    host: server
    database: database,
    max: 25
});
module.exports = {
 execute_query: function (query2) {
    //usage of query
    pool.query('query2', function(err, result){

    return (result);
    });

}
};

Then in my application, the function execute_query is called in different places in the application. Locally it works but I wonder how the pool is managed, is this enough configuration to manage concurrent users if my application is used by different people ? Do I need to do anything else to ensure that I have clients in the pool ? Or should I use the old way of managing clients with a hard code ?

I read the documentation of node-postgres and it says that pool.query is the simplist way but it doesnt say how it manages the connections... Do you have any information ?

Thank you

Jean
  • 429
  • 6
  • 23

1 Answers1

0

is this enough configuration to manage concurrent users if my application is used by different people ?

This is a very broad question and depends on more than one thing. Let me still give this a shot

Number of connection in the pool is the number of active connections your server will maintain with the db. Each connection as a cost as postgres maintains this as a separate process. So just focussing on the connection pool is not enough.

pgtune gives you a good recommendation on your postgresql.conf setting based on your hardware.

If you want to test out your application, you can test using jMeter or any other load testing tool to see how your application will perform under certain load.

Some good resources to read on the topic stack overflow answer, postgres wiki

AbhinavD
  • 6,892
  • 5
  • 30
  • 40
  • Thank you for the answer and the links, they do help me understand the configuration for PostgreSQL – Jean Apr 27 '18 at 07:03