在「MongoDB System Tuning Best Practices」這份投影片裡面看到:
To avoid disk-based swap: 1 (not zero!)
以及:
‘0’ can cause unpredicted behaviour
在 kernel 的說明文件是這樣描述,設成 0
時表示只有在避免 oom 時才會 swap:
This control is used to define how aggressive the kernel will swap memory pages. Higher values will increase agressiveness, lower values decrease the amount of swap. A value of 0 instructs the kernel not to initiate swap until the amount of free and file-backed pages is less than the high water mark in a zone.
設成 1
的想法頗有趣的,來看看在 MySQL 上是不是也有同樣的情況要注意...
有喔大大
https://www.percona.com/blog/2014/04/28/oom-relation-vm-swappiness0-new-kernel/