Interview Prep/Linux/Processes, memory and OOM

A server becomes unresponsive for minutes at a time and then recovers; `vmstat` during the event shows high `si`/`so`.

IntermediateTroubleshootingProcesses, memory and OOM
Answer

Likely causes → Heavy swapping (thrashing): the working set exceeds RAM and the kernel spends its time moving pages.

Diagnose →

vmstat 1
sar -W 1 5                         # pswpin/s pswpout/s
for f in /proc/[0-9]*/status; do awk '/^Name|^VmSwap/{printf "%s ", $2} END{print ""}' $f; done | sort -k2 -n | tail
cat /proc/pressure/memory

Fix → Find the process pushing memory, reduce its footprint or limit it with MemoryHigh=. Add RAM if the workload legitimately needs it.

Prevent → Use systemd-oomd or earlyoom to kill runaway processes before the host thrashes.

All Linux questions Roadmap: Linux

More on Processes, memory and OOM