mongodbwiredtiger

Check cache size of wired tiger in a mongodb


I try to set a limit on the cache size of wiredTiger in a mongodb. First of all, I executed the following command:

mongod --wiredTigerCacheSizeGB 1

I also added the following lines to the configuration file named mongod.conf.orig

storage:
  dbPath: /var/lib/mongodb
  journal:
    enabled: true
#  engine:
#  mmapv1:
  wiredTiger:
    engineConfig:
       cacheSizeGB: 1

and then executed the command:

mongod --config /etc/mongod.conf

To double check my change, I would like to display the currently used cache size of wired tiger.

Is there a possibility to display it?


Solution

  • Login to the database (Atlas or on-prem) and run:

    db.serverStatus().wiredTiger.cache
    

    there's a status variable called "bytes currently in the cache"

    There's also "maximum bytes configured" which should reflect your cache size.