Server is crawling: heavy swapping
When memory runs out the kernel swaps to disk and everything slows down. Confirm swap activity with vmstat, find the memory hog, then add RAM or cap the app.
What you see
- Everything is slow, including a plain shell
vmstatshows non-zerosiandso- Load is high while CPU use is low
What it means
Swap moves memory pages to disk to free RAM. It works as a safety valve, but disk is far slower than memory. When a system swaps constantly, it spends its time moving pages in and out instead of running work, which is called thrashing.
If swapping does not relieve the pressure, the kernel falls back to the out-of-memory killer.
How to confirm the cause
- 1Watch swap in and swap out live
vmstat 1 10
siis memory swapped in from disk per second andsois memory swapped out to disk. Sustained non-zerosomeans active pressure. - 2See memory and swap totals
free -h
Little available memory with swap in heavy use confirms it.
- 3Find the biggest memory users
ps aux --sort=-%mem | head -10
The top few processes are your suspects.
Causes and fixes
A process uses far more memory than expected
- HOW TO TELL
- One process dominates the
pslist and its size grows over time. - ROOT CAUSE
- A leak or an unbounded cache keeps taking memory until RAM is gone.
- FIX
- Fix or restart the process, and set a memory limit so it cannot starve the host.
The host is too small for the workload
- HOW TO TELL
- No single culprit; many processes add up.
- ROOT CAUSE
- The combined working set is larger than RAM, so the kernel has to swap.
- FIX
- Add memory, reduce what runs on the host, or move workloads elsewhere.
How to stop it coming back
- Alert on sustained swap-out, not only on free memory.
- Set limits on containers and services so one cannot starve the rest.
- Size hosts from measured peak use.
Keep going
- Runbook: Process killed by the out-of-memory killer
- Runbook: High load average: is it CPU, disk or memory?
- Cheat sheet: Linux
- Lesson: the linux topic in Learn
Sources
Linux man-pages (man7.org) and the systemd manual (freedesktop.org), read 18 Nov 2026. Command options were checked against those pages.