Stress testing app which uses MongoDB

Hello all. Hope you all are well.
So recently I built an app using NodeJS and was stress testing it. Its a chatting app and each user has a unique ID. A new document is made for each such user ID which consists of an array of objects to hold the conversation of a user. All the conversation that happens with them gets stored in an array of objects in the same document.
I sent about 20,000 requests(messages) using the same userID and in principle, all these should have been stored in the array of this user’s document, however, only a few thousand did.
I am using MongoDB premium and cannot figure out the issue that is causing this.

Hello @Muhammad_Jahanzeb. Welcome to the forum!

Without fully understanding the underlying method you are using to update the records in the db, I’m guessing that the issue could be caused by a race condition, especially if the messages are missing intermittently.

Else, it could also be because you’ve exceeded the document size limit of 16MB, which should also throw an error.
Reference: MongoDB Schema Design: Data Modeling Best Practices | MongoDB

For a high volume of messages, it’s advised to separate the messages into another collection.

When you said MongoDB premium, do you mean MongoDB Atlas?

Perhaps you can share in detail how the messages are getting sent, the exact document structure you’re using, & more details on which part of the messages went missing (in the middle or the messages just end at a certain point).

3 Likes

Relevant old thread: Advice for Chat schema design

I totally agree with

So please share your code so that we can find what is wrong with it.

@Muhammad_Jahanzeb, 9 days since you received some feedback on your issues.

Please provide a followup.