title: Mongodb - make inmemory or use cache
body: <p>I will be creating a 5 node mongodb cluster. It will be more read heavy than write and had a question which design would bring better performance. These nodes will be dedicated to only mongodb. For the sake of an example, say each node will have 64GB of ram. </p>
  
  <p>From the mongodb docs it states:</p>
  
  <blockquote>
    <p>MongoDB automatically uses all free memory on the machine as its cache</p>
  </blockquote>
  
  <p>Does this mean as long as my data is smaller than the available ram it will be like having an in-memory database?</p>
  
  <p>I also read that it is possible to implement mongodb purely in memory</p>
  
  <blockquote>
    <p><a href="http://edgystuff.tumblr.com/post/49304254688/how-to-use-mongodb-as-a-pure-in-memory-db-redis" rel="nofollow">http://edgystuff.tumblr.com/post/49304254688/how-to-use-mongodb-as-a-pure-in-memory-db-redis</a></p>
  </blockquote>
  
  <p>If my data was quite dynamic (can range from 50gb to 75gb every few hours), would it be theoretically be better performing to design mongodb in a way which allows mongodb to manage itself with its cache (default setup of mongo), or to put the mongodb into memory initially and if the data grows over the size of ram use swap space (SSD)?</p>