My mongodb cluster config server use too much memory


config use memory 7GB,and my server has other shading,collection local.oplog.rs has 164764738 records

configRS:SECONDARY> use local
switched to db local
configRS:SECONDARY> show tables;
me
oplog.rs
replset.election
replset.minvalid
startup_log
system.profile
system.replset
configRS:SECONDARY> db.oplog.rs.find().count()
164764738

1 Like

Hi @11122

mongod going to use what you configured plus whatever it can use from the filesystem cache.

With WiredTiger, MongoDB utilizes both the WiredTiger internal cache and the filesystem cache.

Via the filesystem cache, MongoDB automatically uses all free memory that is not used by the WiredTiger cache or by other processes.

https://docs.mongodb.com/manual/reference/program/mongod/index.html#wiredtiger-options

I have the same problem now on version: 4.0.3-1.0.7. Also my config server takes over almost all of memory. The wiredTiger cache size is 1G limited.
It works well on docker with only allocate 2G memory long ago. But someday OOM happens and I have to increase the memory to at least 8G to prevent OOM again. Each of the two shard node only hold 30G data.
How is that happen? I really want to know what the memory is used for. Hope your help!

db.serverStatus().mem
{
   "bits" : 64,
   "resident" : 7214,
   "virtual" : 14690,
   "supported" : true,
   "mapped" : 0,
   "mappedWithJournal" : 0
}
---
# mongostat
insert query update delete getmore command dirty  used flushes vsize   res qrw arw net_in net_out conn                        set repl                time
   *0    *0     *0     *0       2    11|0  0.5% 73.4%       0 14.3G 7.04G 0|0 1|0  1.40k   68.8k   30 mgset-1725952967_configsvr  PRI Oct 28 09:27:09.560
   *0    *0     *0     *0       0     6|0  0.5% 73.4%       0 14.3G 7.04G 0|0 1|0   921b   66.8k   30 mgset-1725952967_configsvr  PRI Oct 28 09:27:10.561
   *0    *0     *0     *0       0    11|0  0.5% 73.4%       0 14.3G 7.04G 0|0 1|0  1.20k   68.6k   30 mgset-1725952967_configsvr  PRI Oct 28 09:27:11.562
   *0     2     *0     *0       0     9|0  0.5% 73.4%       0 14.3G 7.04G 0|0 1|0  1.70k   71.3k   30 mgset-1725952967_configsvr  PRI Oct 28 09:27:12.560
---
# ps aux
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root       161 10.8  2.8 15042880 7387084 ?    SLl   2020 93890:45 /opt/mongo/mongod --config /var/mongo/config/configsvr.conf
---
# cat /var/mongo/config/configsvr.conf
bind_ip = ::,0.0.0.0
port = 27017
ipv6 = true
fork = false
pidfilepath = /home/var/mongod.pid
logappend = true
dbpath = /home/data
logpath = /home/Logs/mongod.log
maxConns = 500
replSet = mgset-1725952967_configsvr
keyFile = /home/etc/keyfile
timeStampFormat = iso8601-local
unixSocketPrefix = /home/var
auth = true
wiredTigerCacheSizeGB = 1
directoryperdb = true
configsvr=true