Over a million developers have joined DZone.

MongoMem: Optimize Memory Use in MongoDB

DZone's Guide to

MongoMem: Optimize Memory Use in MongoDB

· Performance Zone
Free Resource

Transform incident management with machine learning and analytics to help you maintain optimal performance and availability while keeping pace with the growing demands of digital business with this eBook, brought to you in partnership with BMC.

MongoDB users: do you have a way to tell how much memory each collection is using? For the Wish Engineering team, the answer was "no," and that's why they developed MongoMem. MongoMem allows MongoDB developers to precisely locate collections in need of memory-use optimization, rather than searching for problems based on intuition. According to the Wish team's overview of MongoMem, the need was clear: 

In our early days, we kept using a lot more memory than we thought we should be, but we were running blind when we tried to decide where the low-hanging fruit was to optimize. After plenty of frustrating optimizations that didn’t make much difference, we decided that we really needed better information, and MongoMem was born.

The Wish team's overview goes into detail on how MongoMem works - mincore calls and the collStats command do most of the work - what you can do with it, and even details some of the plans for MongoMem's future. Overall, though, it's a pretty straightforward little tool:

For each collection, it prints:

  • Number of MB in memory
  • Number of MB total
  • Percentage of the collection that’s in memory

You can find MongoMem on GitHub (with the usage instructions repeated), so if you're looking for some insight on how to keep MongoDB from overdoing it on memory, this might be a useful tool for you.

Evolve your approach to Application Performance Monitoring by adopting five best practices that are outlined and explored in this e-book, brought to you in partnership with BMC.


Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}