Setting number of MongoDB connections


Is it possible to set the number of connections each Meteor instance makes to MongoDB. We have a little under 20 nodes connected to our MongoDB and they use more than 350 connections which means we have to pay for a higher tier of service to MongoDB Atlas which we’d like to avoid.

Is there a way to limit the number of connections each node makes to the database?

Separately, after vertically scaling up our database, the number of connections dropped from 350 to around 130. The number of connected servers to the database didn’t change, but the connections dropped massively. Could it be there were some hanging connections that got wiped when we scaled up? Or does the amount of RAM/CPU that the database has available to it determine the number of connections too? This latter question may be better suited for a MongoDB forum.


You can use Mongo.setConnectionOptions and pass in the poolSize parameter to set the number of connections in the pool. The default is 5. For example: Mongo.setConnectionOptions({ poolSize: 10 }).