- Joined
- Apr 20, 2016
- Messages
- 107
- Points
- 16
Keep going back and forth on this. The argument for turning it off entirely is that swap only converts a fast death into a slow one, and a server that is thrashing is worse than a server that has restarted.
Where I ended up is keeping swap but setting vm.swappiness low, somewhere around 10. The reasoning is that a long running box accumulates pages that are genuinely cold, daemons that started and never did anything since, and moving those out leaves more room for page cache. That is a real gain even when RAM is not tight. A low swappiness means the kernel prefers reclaiming cache over swapping, so it only reaches for swap when it has a reason.
Turning swap off does not prevent OOM, it just removes the warning. With swap present you usually get a period of degraded performance you can catch on a graph before anything gets killed.
The case I am least confident about is a box whose main job is a database. There the latency spike from touching swap may genuinely be worse than losing the process and restarting. I have not measured that myself. Anyone running dedicated DB boxes with swap off, and did it change what your failures look like?
Where I ended up is keeping swap but setting vm.swappiness low, somewhere around 10. The reasoning is that a long running box accumulates pages that are genuinely cold, daemons that started and never did anything since, and moving those out leaves more room for page cache. That is a real gain even when RAM is not tight. A low swappiness means the kernel prefers reclaiming cache over swapping, so it only reaches for swap when it has a reason.
Turning swap off does not prevent OOM, it just removes the warning. With swap present you usually get a period of degraded performance you can catch on a graph before anything gets killed.
The case I am least confident about is a box whose main job is a database. There the latency spike from touching swap may genuinely be worse than losing the process and restarting. I have not measured that myself. Anyone running dedicated DB boxes with swap off, and did it change what your failures look like?







