Multiple unwanted mongodb connections saturates db deployment

My mongodb deployment is swamped with thousands of connections from my Meteor apps, which enter a state where they create a new connection every few seconds.

More details on:

Please advise, if possible :pray:

Are you opening db connections while the server is running? Are you spawning Meteor sub-processes? How many Meteor servers are you running?

See my reply inline.

There is a total of 11 meteor app instances of different/same bundle which connect to the same mongodb deployment.
All the apps using the deployment are based on meteor :checkered_flag:
btw, that’s our staging deployment. On the production deployment we have only 5 instances.

If you mean that we use Fibers/Future, then yes. 2 apps make use of fibers. Altogether, 5 instances.
We use it to wait for (server-side) and other async ops (i.e. http REST calls to other services).

Yes, we do - at times. In addition to the “normal” Meteor collections (declared at app start), we occasionally run batch operations upon server start i.e. migrations.
For that we use meteor-native-mongo. It’s done via only one type of app on dedicated instances. These instances are not necessarily those which end up with 5k mongodb connections (confirmed via lsof). Furthermore, I’ve already double-checked the instances which do use meteor-native-mongo; right after such a ‘migration’ takes place, the number of connections on the Meteor server is back to a single digit. Almost randomly, it starts growing slowly on different apps/instances.

meteor-native-mongo is the only way we create connections directly to the db, and only on startup. The scope for those calls is destroyed and the connections seem to disappear at that point. In any case, I’d like to reiterate that instances which doen’t use meteor-native-mongo are accumulating connections as well (they don’t even have the meteor-native-mongo package installed)

Lastly, I’d like to add:

  1. There’s nothing new with what we do. We’ve been working this way for a year now. The problem started in the past few weeks. It’s possible that a ‘meteor update’ has triggered it, or that something has been changed on the mongodb deployment side.
  2. Other stackoverflow user/s have bumped into a similar issue. This happened with a deployment hosted on Compose as well. Perhaps there’s an issue with the Compose service which triggers the problem. What are the chances?

Update: rcvd reply from Compose:

For some users the connection count issues appears to be caused by a bug in the node native driver which has been fixed with the v3.1.3 release (it is only about 2 weeks old).

Can anyone tell how to update my Meteor project to use the newer version of the mongodb driver?