Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

    • Consider setting cacheSizeGB appropriately taking into consideration the memory requirements of other processes running on this box.
      With default mongod settings, a box with 16GB memory will most probably be currently set to use more than 7GB of memory for cacheSizeGB.

      This may be too much considering the box may be running NMIS, OMK and other applications too.
      • Check how much memory mongod is using for this cache at /var/log/mongodb/mongod.log:  search for cache_size where it is provided in MB, for example:

        • STORAGE [initandlisten] wiredtiger_open config: create,cache_size=7414M
          cacheSizeGB is set in GB, so a cache_size of 7414M is equivalent to the following setting in /etc/mongod.conf:
          • storage:
            • wiredTiger:
              • engineConfig:
                • cacheSizeGB: 7.24


      • Example where 60% was decided as the ratio that should be used to compute MongoDB cacheSizeGB on a VM with 8GB memory

        • MONGO_USAGE=0.6;echo "$MONGO_USAGE"; 
        • TOTAL_MEM=$(cat /proc/meminfo| grep -iF "memtotal" | awk '{print $2}');echo "$TOTAL_MEM"; 
          • returns  (in KB):
          • returns TOTAL_MEM=7673702.4 (KB)
        • MONGO_MEM=$(echo "(${TOTAL_MEM} / (1024 * 1024)) * ${MONGO_USAGE}" | bc -l);echo "$MONGO_MEM"; 
          • returns (in GB): MONGO_MEM=4.390927734375 (GB)
        • MONGO_MEM=$(printf "%.2f" "${MONGO_MEM}");echo "$MONGO_MEM"; 
          • returns  (in GB):  MONGO_MEM=4.39 (GB)
        • CACHE_MEM_FINAL=$(echo "((${MONGO_MEM} -1) * 0.5) / 1" | bc -l);echo "$CACHE_MEM_FINAL"; 
          • returns  (in GB):
          • returns CACHE_MEM_FINAL=1.695 (GB)
        • CACHE_MEM_FINAL=$(printf "%.2f" "${CACHE_MEM_FINAL}");echo "$CACHE_MEM_FINAL"; 
          • returns  (in GB): CACHE
          • returns CACHE_MEM_FINAL=1.70 (GB)
        • https://docs.mongodb.com/manual/reference/configuration-options/#storage-options
          IF CACHE_MEM_FINAL < 0.25 (GB) THEN CACHE_MEM_FINAL = 0.25 (GB)
        • echo $CACHE_MEM_FINAL
          • 1.7
        • Set cacheSizeGB to 1.7

...