Server feeling sluggish when it shouldn’t? Check your swappiness.
Performance Tuning & Kernel Parameters (Sysctl)
Server feeling sluggish when it shouldn’t? Check your swappiness.
🧩 The Challenge
You’ve got a beefy server, tons of RAM, but every now and then it feels like it’s dragging through treacle. Disk I/O goes through the roof, applications stutter, and `free -h` still shows plenty of available memory. What gives? It’s confusing as hell and can waste hours trying to find a memory leak that isn’t there.
💡 The Fix
Your kernel is probably swapping too aggressively, moving perfectly good application data out to disk even when there’s no real memory pressure. Adjusting a single kernel parameter tells it to calm down and prefer RAM over swap for longer.
sysctl -w vm.swappiness=10
echo "vm.swappiness=10" | sudo tee /etc/sysctl.d/99-swappiness.conf
⚙️ Why It Works
This `vm.swappiness` value, expressed as a percentage, dictates how much the kernel favors moving anonymous memory (your application data) out to swap versus dropping pages from the filesystem cache. A higher number makes it swap sooner, but often unnecessarily. A lower value, like 10, means it’ll hold onto your app’s memory longer.
🚀 Pro-Tip: Never set `vm.swappiness=0` on modern kernels unless you know exactly why; it can actually hurt performance and stability.
Linux Tips & Tricks | © ngelinux.com | 10/1/2026
