I am experiencing some slowdown on my server when a lot of users start using the app. In my attempts to debug the issue, I realized that MongoDB Atlas is experiencing severe slowdowns when I start making concurrent DB request.
In the test case below (Node), I am making 100 concurrent queries to retrieve a simple user document by it`s id (ofcorse indexed).
await Promise.all(
Array.from({ length: 100 }, async () => {
const start = new Date().getTime();
await collection.findOne(ourObjectId);
const end = new Date().getTime();
console.log(`Query executed in ${end - start} ms`, { start: new Date(start), end: new Date(end) });
})
);
The query times start at about 60ms and rapidly start increasing. The 100th query for example ends up taking 854ms.
Is this something expected? Is my test facing some other limitation that I am not seeing?
Here is some info for the MongoDB Atlast configuration
- Users collection contains about 18,000 documents (Altough I tried
with smaller collections and got similar results) - Cluster tier is M50 with 256GB (I even added 3 shards to test but
results did not get better)