node.jsmongodbnode-mongodb-native

Configuring the ideal maxPoolSize on MongoDB Native driver


The default value for maxPoolSize on the MongoClient is 100. How would one know if the default value, 100, is the optimal value? Is there a formula, a way of calculating to determine the ideal maxPoolSize?

Thanks a lot.


Solution

  • The pool size is solely dependent on the driver you are using, for Node.js minimum is 5 which is default and the maximum is 100(default).

    Pool size helps to make the concurrent requests to the DB and it depends upon how much concurrent connection(queries you can run on) you need to create from the application. You can increase it based on your usage- that you have to need more than 100 connections at a time with DB or you need some connections for long-running tasks etc.

    And these connections are of course based on the server that you are running the DB on. Mongo atlas does provide certain clusters that can have up to 1500 connections at a time.

    You should check this post to see how does it impact application performance.