Let's say I have 1k concurrent users who are accessing my website with 80% reads and 20% writes. Currently, the DB size is around 35MB. How much RAM should I have in order for MongoDB to have great performance? I am thinking of going with 4GB of RAM, but just wanted to check what others think.
Thanks!
I think 4G is an overkill, it's unlikely that anything more than 1G will help. The working set itself is 35 MB -- Mongo will never need more than that.
Having said that, you should monitor memory using the linux top or free commands. As long as you are seeing enough free memory, you are good to go. When you see it nearing 80% of your memory, it's time to consider adding more RAM.
But my guess is that you'll run into CPU% issues before you hit memory issues. So, monitor total CPU usage as well -- when you see consistent 50% CPU usage, it's time to consider upgrading the CPU.
Sean Moore
Systems Architect, LookFar
That's a tiny database size, would fit entirely into memory, but according to the docs: "Because MongoDB uses a thread per connection model, each database connection also will need up to 1MB of RAM, whether active or idle." So how big is your pool?
I think 4GB is probably an order of magnitude more than you need right now, but with 1k concurrent users, it sounds like the size of your db is going to grow significantly? Also depends on how you're able to utilize index inserts, which will depend on the sequentiality of your index ids.
How much RAM do you have now? How much is Mongo using? How much has it grown as your app/db size/indexes have grown? What's your performance like now?