We have a number of VMWare recommendations to improve the performance and stability of VM instances hosting MongoDB. Implementing these should improve the performance and reliability for your VMWare instances.
- 100% memory reservation
- Compression is off
- Ballooning is off
mongoD caches as much as it can in memory. Therefore it is normal to see 99%+ memory usage all the time (assuming the database is larger than memory). A good host alerts metric to determine if mongoD is out growing the virual machine is the number of hard page faults. Hard page faults force the process to go to disk to get the information it needs and incur a significant performance penalty. Spinning disks and SANS cannot generally support more than 10 page faults/sec. SSDs can generally support up to 10k page faults/sec before there is a signifcant perforamance impact. Note this depends on the specific SSD model disk configuration in question. For the best performance ensure:
Our recommendation is to reserve sufficient memory in the hypervisor for the MongoDB VMs to ensure the database's working set fits within it. This VMWare guide covers using reservations in VSphere. This also avoid issues with memory overcommitment in your VM (see this doc for more information).
- Set a 100% reservation for your VM appropriate to your working set for MongoDB
- Disable memory compression
- Reserve CPUs
We recommend 2-4 CPUs per server (the heavier the read load the more CPUs you'll need). Reserve these CPUs. mongoD's write performance is great impacted by latency, having the CPU switched out from undernearth the writing thread can lead to spikes in the write lock.
- Use paravirutalized drivers
We have seen a significant performance improvement with VMWare VMs hosting MongoDB using paravirtualized IO drivers. If this is available for your VM, please update your configuration to use them.