listCollections performance issue in 4.2

Hi there,
We have an application in production with API servers, developped in .Net Core. The APIs call a MongoDB cluster hosted on premise.
We have 10 server, and each servers contains 40 API instances.
We used to perform a healthcheck every 5 s on each API instance. This healthcheck simply connects to MongoDB and calls listCollections.
Everything was working fine till MongoDB 4.0, but when we migrated to 4.2 performances decreased a lot. We found out that the healthcheck was responsible of this situation. It is like if listCollections puts some locks or something it did not do before. One we deactivated healthCheck, everything was fine.
However this makes me worry about other performances issue.
Has anyone encounter such issue when migrating to 4.2 ?

Hi @David_DOUSSOT,

Does your command use a plain listCollection command or have a nameOnly : true provided.

A flag to indicate whether the command should return just the collection/view names and type or return both the name and other information.

Returning just the name and type ( view or collection ) does not take collection-level locks whereas returning full collection information locks each collection in the database.

I believe the locking mechanism of list collection is responsible for the performance issue.

In general you can consider using other commands like “isMaster” or rs.status() to perform a health check.

Best regards,

Thank you for this tip Pavel !
There’s actually a new version of this healthcheck function which performs “listCollectionsNames” instead of “listCollections”. This could explain…
We’ll try and I’ll tell if it was efficient.