Intro Linux overcommit_memory For Redis

Intro Linux overcommit_memory For Redis

這篇介紹Linux overcommit_memory For Redis。

前情提要

1
2
3
4
5
在Redis Server啟動時會出現

WARNING overcommit_memory is set to 0! Background save may fail under low memory condition.
To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run
the command 'sysctl vm.overcommit_memory=1' for this to take effect.

Modify setting

1
修改 /proc/sys/vm/overcommit_memory 0 to 1

overcommit_memory

1
2
3
4
5
6
7
8
9
10
定義接受或拒絕大型記憶體需求的狀況。此參數有三種可用值:
0 — 預設設定。kernel 會進行探索式的記憶體過度寫入處理,方法是預測記憶體的可用量、
並讓公然違規的需求失敗。不幸的是,因為記憶體是以探索式、而非精準的演算法則來分配,
因此這設定有時會過度使用系統上的可用記憶體。

1 — kernel 不進行記憶體過度寫入處理。在此設定下,過度使用記憶體的機會會增加,但對於
頻繁存取記憶體的任務來說,效能也會增加。

2 — kernel 拒絕相等或大於總可用置換空間與實體記憶體比例(於 overcommit_ratio 指定)
的記憶體需求。如果您想要降低記憶體過度寫入的風險,這是最佳設定。