grafclouds.com / documents / insights / training / devops-challenges / linux-oom-swap-tuning

The Box Keeps OOM-Killing. Just Add a Huge Swapfile?

Advanced ~13 min read
LinuxObservability

Scenario

A latency-sensitive service keeps getting shot by the kernel. Under peak load, memory on the VM spikes, the OOM killer picks the service process, and users see a burst of 5xx errors until the process restarts. The machine has limited RAM and no swap configured. Crucially, nobody has actually established why memory grows — it might be a legitimate working set that outgrew the box, a slow leak, or transient allocation spikes under load. All three look identical on a dying host.

A colleague offers the classic sysadmin reflex: "Add a 16GB swapfile and crank vm.swappiness up. The kernel will page to disk instead of killing the process. No more OOM kills, no more 5xx."

The Quick Fix on the Table

Provision a big swapfile and tune swappiness so the kernel prefers paging over killing. Two commands, no deploy, and the OOM messages disappear from dmesg almost immediately.

Interview · Round 1

The quick fix is on the table and the room is waiting for your call. Would you sign off on it? Take a position and justify it — out loud or on paper — before revealing the analysis.