Hi there,
I need to correctly size MongoDB dedicated memory in my architecture.
I have a 3 node Replica Set running on Docker Swarm with other services.
I started with no memory limits (containers see the total amount of RAM of the host) and I’ve found that MongoDB is eating up memory day by day (even more than 10GB in my case) because he usually use 50% of RAM for wiredTiger cache and seems not to release it (or release very slow). The 50% rule can probably be good if the machine is MongoDB dedicated but if you have other services (like me) this leads the machine to swap a lot in the long term (solved with reboots in last months).
Now I’m digging into it and I’ve found I can limit the memory on container via Docker and/or via --wiredTigerCacheSizeGB
option directly from mongod
.
I’m trying with 6GB limit on containers letting MongoDB managing the wiredTiger cache size (db.serverStatus().wiredTiger.cache['maximum bytes configured']
reports 2.5 GB).
Actual usage (from docker stats
):
Percona MongoDB 8.0
Primary node mem usage 5.417GiB / 6GiB
Secondary node mem usage 2.595GiB / 6GiB
Secondary node mem usage 2.711GiB / 6GiB
Primary (db.serverStatus().wiredTiger.cache
formatted)
{
'maximum bytes configured': '2.50 GB',
'bytes currently in the cache': '2.00 GB',
'tracked dirty bytes in the cache': '0.01 GB'
}
Secondary (db.serverStatus().wiredTiger.cache
formatted)
{
'maximum bytes configured': '2.50 GB',
'bytes currently in the cache': '2.00 GB',
'tracked dirty bytes in the cache': '0.01 GB'
}
Secondary (db.serverStatus().wiredTiger.cache
formatted)
{
'maximum bytes configured': '2.50 GB',
'bytes currently in the cache': '1.68 GB',
'tracked dirty bytes in the cache': '0.01 GB'
}
Primary container is on 90% usage and the memory warning is often triggered.
Is this primary/secondary difference ok?
This means that the primary is using 3.417GiB (5.417GiB - 2.00 GB) of RAM that is not wiredTiger cache?
Do you know approximately how much RAM MongoDB needs, net of cache?
Is this proportional to the number/size of dbs to be managed?
I’m still studying so corrections and suggestions are appreciated
Thanks in advance for the patience