What are the RAM requirements like between MongoDB and MySQL for the same data set and usage? (i.e. under the exact same scenario, how much RAM will each use)?

It is true that MongoDB keeps the full database in RAM?


mongo will attempt to always keep the whole database in RAM.. but as the OS needs RAM for other apps it will release parts that mongo uses.

The thing mongo needs to keep in RAM is the indexes to stay fast.

In my application mongo uses a lot less RAM then mysql but it really depends on how many indexes you have and the size of your data set.


A major issue with Mongo for large datasets is that Mongo uses memory mapped files. There is no way to limit the amount of ram Mongo will try to use on a machine. So it basically expects the entire resources of a machine, a dedicated box. This is only an issue if your data is large and especially when your indexes are bigger than ram. To answer your question about data, MongodDB will really only try to keep the indexes in RAM.

  • Since v3.2 WiredTiger is a default storage engine. – Evgeni Nabokov Jan 21 '17 at 16:53

We have small cluster (2 shards), and the main points we have got:

1) MongoDB store indexes in RAM and as much data as possible (as answered above) yes, it's true The best way is store ALL data in ram. (our project has about 1 million unique users/day and about 30 million requests => storing all data in ram so important for us).

2) If your ram size is over - its time to divide your mongo server (fortunately, in MongoDB it's very easy to configure)

The main storage we use, is about 40gb data and 10gb indexes. Works on two shards 32GB ram each.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.