Ramblings of an aging IT geek
← Ramblings of an aging IT geek
linux

yes i still run swap, and here is the one setting that matters

A short note on why I keep a small swap partition on my homelab boxes and why swappiness, not the swap itself, is the real lever.

A terminal showing system memory stats

Every few months someone declares that swap is obsolete because RAM is cheap, and every few months I disagree by leaving it on. The argument "just buy more RAM" misses what swap is for. It is not there to pretend you have more memory. It is there so the kernel can evict pages that genuinely never get touched, and hand that RAM to the page cache where it does some good.

On my homelab boxes I keep a small swap, a couple of gigabytes, and then I set the lever that actually matters:

vm.swappiness = 10

The default of 60 is tuned for desktops. On a server with services I care about, 10 tells the kernel to prefer dropping cache over swapping anonymous pages, but still allow swap when something is truly idle. The failure mode people remember, the box that grinds to a halt thrashing swap, is almost always a memory leak or an OOM situation, not swap doing its job. Swap did not cause that. It just made it visible instead of letting the OOM killer fire blind.

So the debate is settled, for me at least: small swap, low swappiness, and an alert if anything actually starts paging hard. Turning it off entirely just means the OOM killer makes the decision for you, and it is a worse decision than the kernel paging out a daemon that has not woken up since the box booted.