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?
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.Sign up to join this community
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.
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.