Hi @S_P and welcome in the MongoDB Community
!
MongoDB needs memory for several things:
- connections
- indexes
- working set
- read/write operations & aggregations, in-memory sorts, etc.
Which is, of course, on top of what your OS is consuming. So for example, when you run a query, it will first create a connection which will consume RAM and then release it (if you close it…). But it will also consume RAM to run the query and retrieve documents from disk which will then stay in the working set (most frequently used documents), until they are replaced at some point by more recently needed documents.
Indexes can also get smaller or bigger of course, but they need to fit in RAM to ensure good performances.
Usually, in most use cases, about 10-20% of RAM compared to the cluster size is about right. So 10 to 20GB or RAM for 100GB of data is about right.
With only 8 GB of RAM and a bunch allocated for the OS, I guess you shouldn’t have more than 60GB or so of data without too many indexes and large in-memory sorts and aggregations. You would require more to support theses correctly.
MongoDB tends to use all the RAM available to keep documents in RAM & avoid disk accesses. Too many IOPS can potentially be solved by adding more RAM as less docs would be evicted from the RAM too early and would need to be fetched from disk.
Cheers,
Maxime.