How MongoDB closes connections on the server side?

When I’m closing the app the connection keeps alive for 15-20 seconds. Which is normal, I assume. But some connections keep alive longer. For example, I have 18 now in my Atlas without any connected clients (except the checking script).

I’m using pymongo as a driver on the client side.

Hi @Roman_Right and welcome in the MongoDB Community :muscle: !

MongoDB Atlas also uses internal connections. For example it’s using a few to replicate the data from the Primary to the Secondaries. There is also a health check (heartbeat) every 2 seconds by default if I remember correctly.
I guess there are also a few for the monitoring.


1 Like