MongoDB uses both the internal WiredTiger cache and the file system cache when WiredTiger storage engine is used. The default internal cache takes up to a minimum of 256 MB and caps at 50% of (MEM – 1 GB). With file system cache, MongoDB automatically uses up the rest of the free memory available on the system.
WiredTiger compression can reduce the amount of memory consumed by keeping the data in the file system cache the same format as the compressed data on disk. The indexes in the internal cache can also benefit from the index prefix compression. However, the data in the internal cache is uncompressed.
In all test cases, MongoDB processes and file system cache consumed most of the system memory (over 92%). The average memory consumption of the virtual machines is lowest when using the zlib or zstd algorithm, which ranges between 92% to 95%. Conversely, the average memory consumption is higher with the snappy compression or no compression is used, which is close to 99%.
For CPU consumptions, all virtual machines consumed similar amount of CPUs, which ranges between 42% to 48% in all test cases.