If you’ve ever had a small Debian server that technically is still alive, ping works, uptime is fine, but SSH becomes painfully slow and your apps feel like they’re moving through syrup, there’s a good chance you’ve met the quiet villain, disk swap.
Linux is incredibly smart about memory management, but on machines with limited RAM (1–4GB is the usual battlefield), it can sometimes start swapping earlier than you’d expect. And the moment that swapping becomes heavy, the server can feel like it’s frozen even if the CPU isn’t maxed out.
The fix often isn’t “add more swap” or “buy more RAM” (although those help). The fix is to teach the kernel a simple preference
Use RAM first. Use swap only when it’s really needed.
That preference is controlled by a kernel parameter called
vm.swappiness
What “swappiness” really means (in human terms)
Swappiness is a number that influences how aggressively the kernel moves memory pages out of RAM and into swap space.
- Higher value > kernel is more willing to swap
- Lower value > kernel tries harder to keep things in RAM
Most distros default to something around 60, which is generally fine for modern machines with plenty of RAM. But for small servers, especially those running databases, Node.js apps, Strapi, queue workers, or anything with bursts of memory usage, that default can be too eager.
The classic symptom looks like this
- your app suddenly slows down
- SSH input lags
- “top” shows nothing dramatic
- disk activity spikes
- everything feels “stuck” until it recovers
That’s why a very common, practical baseline tweak is:
Set swappiness to 10.
It doesn’t disable swap. It simply lowers the priority of swap so your server stays responsive longer.
Before changing anything, check your current state
Start by confirming your current memory and swap situation:
free -h
swapon --show
cat /proc/sys/vm/swappiness
If you see swappiness is 60, you’re looking at the common default.
Set vm.swappiness=10 (immediate effect)
To apply it right now (until the next reboot)
sudo sysctl -w vm.swappiness=10
Then confirm
cat /proc/sys/vm/swappiness
At this point, Debian 13 will behave noticeably better under memory pressure: it will try harder to keep active application memory in RAM instead of pushing it out to disk.
Make it permanent on Debian 13
A reboot will reset the value unless you persist it. The clean Debian way is to add a sysctl drop-in
echo "vm.swappiness=10" | sudo tee /etc/sysctl.d/99-swappiness.conf
sudo sysctl --system
Re-check
cat /proc/sys/vm/swappiness
Done. Debian will apply this automatically on future boots.
How to tell if it’s working
The best confirmation isn’t a number, it’s behavior. Your server should remain usable longer when traffic spikes.
If you want to watch swap activity live, install sysstat and use vmstat
sudo apt install -y sysstat
vmstat 1
Look at:
si= swap inso= swap out
Ideally, those numbers stay at 0 most of the time, occasional swap usage is normal, constant swap in/out is where performance dies.
The important nuance for small memory: don’t remove swap blindly
When people feel swap pain, the first instinct is, “Okay, no swap at all.”
On small RAM machines, that can backfire.
Swap is still useful as a safety net. Without it, when memory runs out, Linux may trigger the OOM killer and terminate processes (sometimes the wrong one). So the best balance for most small servers is
- Keep swap enabled
- Lower swappiness so swap becomes “last resort”
That’s exactly what vm.swappiness=10 does.
If you truly want “no disk swap” but still want safety, the modern solution is zram (compressed swap stored in RAM). That’s a separate topic, but it’s worth it for tiny VPS nodes.
Suggested values (what I actually use in practice)
- General small server (1–4GB RAM):
10 - Database-heavy or latency-sensitive services:
1–10(start with 10, then test) - If you still see heavy swap churn: consider zram, or add RAM
No one number is perfect, but 10 is a great baseline because it reduces swap pain without turning off the safety net.
Rollback (if you need to revert)
Temporary revert to a common default:
sudo sysctl -w vm.swappiness=60
Permanent revert:
sudo rm -f /etc/sysctl.d/99-swappiness.conf
sudo sysctl --system
Cheat sheet
# Check
free -h
swapon --show
cat /proc/sys/vm/swappiness
# Set now
sudo sysctl -w vm.swappiness=10
# Persist
echo "vm.swappiness=10" | sudo tee /etc/sysctl.d/99-swappiness.conf
sudo sysctl --system
# Observe swap activity
sudo apt install -y sysstat
vmstat 1
Closing thoughts
On small-memory servers, performance issues often don’t come from CPU, they come from the kernel quietly shuffling memory pages onto disk. The machine is “up”, but the experience is awful.
vm.swappiness=10 is one of those small changes that turns a fragile VPS into a predictable one: fewer freezes, better responsiveness, less panic during spikes. It’s not magic, but it’s a solid baseline, especially if you run web apps and databases on limited RAM.