Closing connections to Atlas Cluster from HTTP Webhooks

I’m using a Realm app to query my Atlas cluster through a HTTP Webhook.
My Service function is something like this:
exports = function(payload, response) {
const movies = context.services.get(“mongodb-atlas”).db(“sample_mflix”).collection(“movies”);
… Do some search related stuff here …

Everything is working fine but I see the connections (in the Atlas UI) to my cluster keep increasing. Started off at 2 a couple of days ago, and it is at 22 right now. I am the only person testing this app out right now, so there’s shouldn’t be too many connections.

Have read about connection pooling and closing connections after a time interval, but I can’t seem to find anyway to do that in the Webhook.

Any suggestions on how I can keep my connections from hitting the limit?

Hi @Sunil_Daman ,

Welcome to MongoDB community.

Realm apps use connection pooling to optimise atlas cluster connections.

As workloads coming in idle connections might be present but it shouldn’t pose any risk or performance issues to your cluster and will never grow close to cluster limit.

Thanks
Pavel