MongoDB Document of Size 300kb taking 8-15s

I am using MongoDB Atlas Free Tier hosted on GCP. I have documents which have arrays containing 300kb data. A simple Get By ID query takes around 8-15 seconds. There are less than 50 records in the collection so probably indexing is not an issue. Also, the I have used my custom Ids, and not the built in ObjectIds in my collection. Is this much query time normal? If yes, what are some ways to address this issue as I need fast realtime analytics on Frontend. I already have Redis in mind, but is there any better way to address this?

Stack Overflow Asked by Liqteq Developer on November 22, 2021

2 Answers

2 Answers

  1. Ensure your operations are not throttled.

  2. Test performance with a different driver (another language), verify you are using most recent driver releases.

  3. Test smaller documents to identify whether time is being expended on the server or over the network.

  4. Test with mongo shell.

Answered by D. SM on November 22, 2021

As for an answer, I highly recommend you not to deal with M0 Atlas tier. Or at least choose it wisely, don't choose US-based cluster if you thousand of miles away from States side. Don't understood me wrong. It's a good product. But it depends on your costs.

As for myself, I prefer to deal with MongoDB Community Edition version and deploy it on my VPS/VDS. Of course it doesn't provide you such good web-interface like you have seen in Atlas. And there is no support of Realms functional (stitch), but instead you could design it yourself. And also, every performance issue is depend on you.

As for me, I using MongoDB not for real-time data, but visual snapshots on front-end, and I have no problems with performance.

I mean if I have them, then I deal with them myself, via indexing, increasing VPS CPU/RAM, optimizing queries and so on

Also, one more thing about your problem: «I have documents which have arrays containing 300kb data»

If you have an array field in your schema, and it stores lots of data, especially if it's embedded docs, are you sure that you are using right schema pattern?

You might wanna take a look at this articles at Mongo University about architecture patterns.

Probably it will be much better for you to have a different collection for embedded docs, and request them via aggregation.$lookup when they needed.

Answered by AlexZeDim on November 22, 2021

Add your own answers!

Related Questions

SSL for pointed domains

1  Asked on February 24, 2021 by userhex


Encrypt message using RSA on ESP32

0  Asked on February 24, 2021 by daniel-tang


Counting the occurrences of a substring in a string python

2  Asked on February 24, 2021 by indrajith-ekanayake


C# calculations differ between const and variable locals?

1  Asked on February 24, 2021 by ren-van-den-berg


How do i call API with multiple parameters in android studio

3  Asked on February 23, 2021 by shane


How to fix dict to pandas dataframe

1  Asked on February 23, 2021 by spatial-digger


C Polynomial Addition exercise

3  Asked on February 23, 2021 by aaa


Fill a list with a for loop python

3  Asked on February 23, 2021 by dottorbooom


Ask a Question

Get help from others!

© 2021 All rights reserved.