Stop your server from swapping itself to death with plenty of RAM
Performance Tuning & Kernel Parameters (Sysctl)
Stop your server from swapping itself to death with plenty of RAM
🧩 The Challenge
Ever had a server, maybe a database or a busy web app, with tons of free RAM, but it’s still dragging its feet because it’s constantly hitting swap? It’s infuriating when `free -h` shows gigabytes available, but your I/O wait is through the roof.
💡 The Fix
You can tell your kernel to be less aggressive about moving perfectly good pages out to slow disk swap. This keeps frequently used data in fast memory where it belongs, dramatically improving latency for memory-sensitive apps.
sysctl vm.swappiness=10
echo "vm.swappiness = 10" > /etc/sysctl.d/99-swappiness.conf
⚙️ Why It Works
That `vm.swappiness` parameter controls how much the kernel favors swapping out anonymous memory pages (application data) versus reclaiming page cache (filesystem data). Setting it low, like 10, means the kernel will try harder to keep applications in RAM.
🚀 Pro-Tip: For dedicated database servers, sometimes a `swappiness=0` or `1` is even better if you know you have enough RAM. Just watch your memory usage!
Linux Tips & Tricks | © ngelinux.com | 10/25/2026
