MongoDB take up too much memory frequent downtime

Look at some documentation:

Starting MongoDB 3.4, the default WiredTiger internal cache size, whichever is the greater of:

50% (RAM-1 GB), or 256 MB.

For example, the total system of the 4GB RAM, WiredTiger caches to 1.5GB RAM ().
In contrast, 1.25 GB of total memory cache allocation system will WiredTiger 256 MB, because this is more than half of the total RAM minus 1 GB ().

// 4GB
0.5 * (4 GB - 1 GB) = 1.5 GB

// 1.25GB
0.5 * (1.25 GB - 1 GB) = 128 MB < 256 MB

After reading the document, I see his memory usage

$ free -h
# 没启动mongod
            total        used        free
Mem:         3.7G        2.4G        1.3G

# 启动mongod
            total        used        free
Mem:         3.7G        1.8G        364M

Direct memory filled up

Reference part of the online article, roughly meaning that, MongoDB taking up too much memory, kill off the system, so downtime phenomenon

Solutions

Add two parameters

Modify the configuration mongodb.conf

# 为高速缓存分配的最大内存量;默认为物理RAM的1/2
# wiredTigerCacheSizeGB <float>
wiredTigerCacheSizeGB=0.5

# 最大同时连接数,默认1000000
maxConns=1000

reference

  1. mongo memory limit wiredTigerCacheSizeGB = 10
  2. wiredTigerCacheSizeGB
  3. MongoDB memory configuration --wiredTigerCacheSizeGB
Released 1399 original articles · won praise 355 · Views 1.27 million +

Guess you like

Origin blog.csdn.net/mouday/article/details/104255674