Mongo 6 consumes far less memory than Mongo 4?

This is certainly not a complaint, but I am curious as to why Mongo 6 appears to consume in general far less memory than Mongo 4, with the same hardware, replica-configuration, same data, same indexes, same user activity, etc. I am no longer seeing large memory spikes that I used to see on Mongo 4 (sometimes resulting in swap usage), but the downside is that on a 64gb RAM machine, only about 20% appears to be used and remains consistently flat.

The only notable difference between my Mongo 4 setup and Mongo 6 is that I now have symbolic links of diagnostic.data, journal and local folders to a local SSD disk, separate from database data on a SAN.

Has there been some notable change between Mongo 4 and Mongo 5 that should see me allocate less resources to RAM and perhaps to CPU instead?

Hi @smock

Well this is certainly a good thing isn’t it :slight_smile:

There are large updates to WiredTiger between MongoDB 4.0, 4.2, 4.4, 5.0, and 6.0, so it depends on which “MongoDB 4” you’re talking about.

Without knowing your exact situation and use case, if I have to guess it’s perhaps due to multi document transaction, read concern majority, and replica set synchronization improvements, and constant improvement in WiredTiger internals. You mentioned that older versions have large memory spikes; typically this was caused by the need to keep multiple versions of documents in WiredTiger memory that occurs when the workload requires WiredTiger to do so (transactions is one reason, among many). Newer WiredTiger have a mechanism that does not need to keep them all in memory so that is in line with memory usage improvements you are seeing.

Note that this is just a sweeping generalization and may not be what you experienced at all :slight_smile:

That could mean that your hardware is now overprovisioned for the workload with those WiredTiger improvements. However I would be very careful in changing anything and would carefully examine all the angles before concluding anything.

Best regards
Kevin

1 Like