Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

How Much RAM Should You Have for MongoDB?

DZone's Guide to

How Much RAM Should You Have for MongoDB?

· Database Zone ·
Free Resource

Running out of memory? Learn how Redis Enterprise enables large dataset analysis with the highest throughput and lowest latency while reducing costs over 75%! 

Why RAM is So Important?
RAM is much faster than hard disks. For example, we gained X7 performance boost when we used MySQL In Memory engine rather than InnoDB engine.
Is It Only For Query Caching?
Most of us are familiar with query caching, when results of a query are saved in cache in case it will be called again.
However, RAM can be used to store a copy of your database in the RAM as well. This enables you getting best performance even when you do queries that were not done before. 
So How Much RAM Do I Need?
My Recommendation that your system RAM should be larger than MongoDB data files + index files: SizeOf(RAM) > SizeOf(Data Files) + SizeOf(Index Files).
That way, your files will always be in memory and you will avoid swapping.
What If My Data is Too Big?
In this case you should choose one of the following strategies:

  1. Shard your MongoDB between several servers.
  2. Tune your queries (this is a good idea in general).
  3. Design your databases and collections to support "Data Hierarchy".
  4. Choose SSD as your hard disk solution.
  5. Consider vSMP Foundation for Memory Expansion fromScaleMP to increase RAM up to 256TB as our readers suggested (P.S don't forget them to ask for the special price :-)

Bottom Line
Careful design will do miracles to your production environment.

Running out of memory? Never run out of memory with Redis Enterprise databaseStart your free trial today.

Topics:

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}