The Box Keeps OOM-Killing. Just Add a Huge Swapfile?
A latency-sensitive service keeps getting OOM-killed and a teammate wants to add 16GB of swap and crank swappiness. Defend what you actually do instead.
Answer key reviewed by Branko Petric
Read first: Linux Performance Monitoring and Troubleshooting
Your decision
A latency-sensitive service keeps getting OOM-killed on its VM, and a teammate says just add 16GB of swap and crank vm.swappiness so the kernel stops killing it. What do you do, and why?
The situation
A low-latency service running on its own VM keeps getting terminated by the kernel OOM killer under load. Each kill lines up with a spike of 5xx errors while the process restarts, so users see periodic failures during busy periods. dmesg shows the familiar "Out of memory: Killed process" lines, and the service's memory footprint is clearly climbing toward the ceiling before each event.
Context
The VM has no swap configured and a fixed amount of RAM. A teammate wants to add a 16GB swapfile and raise vm.swappiness so the kernel pages the process out to disk instead of killing it, arguing that this will stop the kills and end the 5xx spikes. You have not yet determined whether the growth is a genuine working-set that exceeds RAM, a memory leak, or a transient load spike.
Worked interview answers
- How to Prepare for an SRE Interview: What Each Round Tests and How to Practice It
How to prepare for an SRE interview, round by round: coding, Linux and networking, SLO-based design, incident deep-dives and behavioral, plus a 4-week plan.
- Linux Troubleshooting Interview Questions: Triage Order, Commands and the Pushback
Linux troubleshooting interview questions, worked: disk full, high load, OOM kills, permission denied, a bad sysctl and a 502, with commands and the pushback.
Related challenges
- Disk Is at 100% and the App Is Down. rm -rf?
A server is out of disk and the app is down. A teammate wants to rm -rf the logs to free space fast. Defend what you actually do first.
- Deploy Fails with Permission Denied. chmod 777 Everything?
A deploy fails with permission errors and a teammate wants to chmod -R 777 the app directory so it never happens again. Defend fixing the actual ownership mismatch instead.
- The Fix Is One Line in /etc. Just SSH In and Edit It?
Prod is degraded by one wrong sysctl value in /etc on an Ansible-managed fleet. A teammate wants to hand-edit each box now and codify it later. Defend the call.
- Pods Keep OOMKilling: Scale Up or Fix the Leak?
A service OOMKills every few hours. Adding replicas or raising memory limits buys time. Defend whether to scale around it or fix the root cause.