how to release the caching which is used by Mongodb?

前端 未结 4 1585
无人共我
无人共我 2020-12-01 02:18

Mongodb use the Memory Mapped File ,when I use a long time , I see the free memory has left less by command \'free -m\' in ubuntu and the caching use a lot. Then kill the Mo

4条回答
  •  广开言路
    2020-12-01 02:54

    What was my issue:

    Because the application deployed on machine from very long time and no historical data was removed which caused increase in size of database used with application. Mongodb occupies almost more than double the size of available data in RAM which was not leaving any free memory to run application.

    Memory status before data deleted:

    [root@ip-172-31-1-173 logs]# free -m total used free shared buff/cache available Mem: 15630 11462 146 732 4021 3207 Swap: 0 0 0

    Memory status after data deleted:

    [root@ip-172-31-1-173 mongo]# free -m total used free shared buff/cache available Mem: 15630 5849 5234 788 4545 8763 Swap: 0 0 0

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

    Changed in version 3.2: Starting in MongoDB 3.2, the WiredTiger internal cache, by default, will use the larger of either:

    60% of RAM minus 1 GB, or
    1 GB.
    

    For systems with up to 10 GB of RAM, the new default setting is less than or equal to the 3.0 default setting (For MongoDB 3.0, the WiredTiger internal cache uses either 1 GB or half of the installed physical RAM, whichever is larger).

    For systems with more than 10 GB of RAM, the new default setting is greater than the 3.0 setting.

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

    You also need to repair database when you cleanup your historical data to maintain size of used cache.

提交回复
热议问题