Swap Thrashing and “No Swap”: Fixing Memory-Pressure Slowdowns

Updated 2026-11-01

A server that goes molasses-slow under load — but doesn't OOM-kill anything — is a classic sign of a swap problem. Either there's no swap at all (so the kernel has no room to page and everything stalls on memory reclaim), or swap is present but tiny and the box is thrashing: paging the same memory in and out constantly.

Check what swap exists

swapon --show            # empty output = no swap at all
free -h                  # Swap row: total/used/free
vmstat 1 5               # high si/so columns = actively thrashing

Add (or restore) swap

fallocate -l 2G /swapfile && chmod 600 /swapfile
mkswap /swapfile && swapon /swapfile
# make it survive reboot — add to /etc/fstab:
#   /swapfile none swap sw 0 0

Tune, don't just add

Swap is a safety margin, not a substitute for RAM — if you're thrashing, the real fix is more memory or less memory pressure. vm.swappiness controls how aggressively the kernel pages; lower it on latency-sensitive boxes. When the kernel runs out of options entirely, you're into OOM-killer territory — swap exhaustion and OOM are two stages of the same memory-pressure story.

Practise it

Memory-pressure slowdowns are part of the simulator's Linux incident set. Drill them in Linux troubleshooting practice.

Learn it by doing

Create a free account and practise on a live fleet.

← All guides