Network latency server <-> Atlas (not happening on local MongoDB)

Hello I recently had a problem with Atlas and I would like to have your opinion on the subject.

In fact, I have created a very simple process that retrieves the elements of a collection called “balances” (this collection contains about a hundred elements in total).
This works very well on a local mongo database (response time of a few seconds), but when trying on the remote mongodb Atlas database, the same code takes several minutes to read and display the same entries.
Since in both cases I tested with the same code and the same entries in the DB, I suspect a latency in the connection server <-> Atlas DB.

I can’t find answers on the internet so I would like to know whether you have an idea of the reasons behind this latency.

Thank you in advance for your feedback,
Yasmine from TEO

Hi Yasmine,

Usually when folks report that there is unexpectedly high latency, this is either because they’re not testing from within the same region on Atlas, or instead because they’re opening a new connection for every query. When using MongoDB Atlas, connectivity requires TLS/SSL (encryption over the wire) and SCRAM authentication. There is a work function implicit in this connection protocol which does take on the order of 100ms to run. However, after a connection is opened, it can be re-used in your code.

Is it possible that you’re opening and closing connections unnecessarily or if it looks like something else may be going on?


1 Like