Tame Your Server’s Swap Obsession

Performance Tuning & Kernel Parameters (Sysctl)

Tame Your Server’s Swap Obsession

🧩 The Challenge

Ever had a server with 64GB of RAM feel sluggish, even with plenty of free memory showing? You’re scratching your head, checking CPU, I/O, everything looks fine, but the system just *feels* slow, and then you realize it’s hitting swap hard. Drives you nuts.

💡 The Fix

Your Linux kernel is probably too eager to push active memory pages to disk, even when there’s no real memory pressure. You can adjust a single kernel parameter to make it much less aggressive about swapping, keeping performance snappy where it matters.

sysctl vm.swappiness=10
echo "vm.swappiness = 10" > /etc/sysctl.d/99-swappiness.conf

⚙️ Why It Works

By default, Linux can start swapping even when there’s a good chunk of physical RAM free. Setting `vm.swappiness` to a low value (like 10 or even 0 if you’re really bold and have tons of RAM) tells the kernel to prefer keeping pages in RAM over swapping them out, unless it absolutely has to. And it’ll mostly swap truly idle pages or cache.

🚀 Pro-Tip: Don’t set it to 0 unless you have a good reason and plenty of RAM. A little swappiness helps prevent out-of-memory errors on very busy systems.

Linux Tips & Tricks | © ngelinux.com | 9/25/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted