Julien TASSIN
Julien TASSIN

Reputation: 5212

Be notified when the poolsize is reached

In order to improve the pool design of an application, I would like to be notified (ideally with an event) when the pool size of an application is reached. This way, I can add a log, if this log occurs too often I will increase the pool size.

With a mongo client initialized this way :

const client = new MongoClient(url, {
  poolSize: 10,
});

Is there a way to be notified when the 10 connections are reached within my application ?

Upvotes: 0

Views: 33

Answers (1)

D. SM
D. SM

Reputation: 14520

Use connection pool events. These should be implemented by all recent MongoDB drivers.

Node documentation

Documentation/example in Ruby

For your question you would track the pool size using ConnectionCheckOut*/ConnectionCheckedIn events if your driver does not expose the pool size or the pool at all directly.

Upvotes: 1

Related Questions