Site icon New Generation Enterprise Linux

Stop your server from crawling when memory gets tight

Performance Tuning & Kernel Parameters (Sysctl)

Stop your server from crawling when memory gets tight

đź§© The Challenge

You’ve probably seen your database server turn into a sluggish brick the moment it hits swap, even when you have perfectly fine RAM left over. It’s infuriating when the kernel decides to get aggressive and swap out active application memory just because it wants a tiny bit more room for the filesystem cache.

đź’ˇ The Fix

Tell the kernel to back off on its swap hunger by adjusting the swappiness value. Lowering this number forces the system to prioritize keeping your apps in physical RAM rather than dumping them to disk at the first sign of pressure.

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

⚙️ Why It Works

Setting this to a value like 10 instead of the default 60 keeps the kernel from being overly eager to move process memory to swap unless it’s absolutely necessary. Most modern servers run much better when they aren’t constantly shuffling pages around like a bored librarian.

🚀 Pro-Tip: Keep it around 10; don’t set it to 0 unless you want your kernel to ignore swap entirely until an OOM event triggers, which usually ends in a panic.

Linux Tips & Tricks | © ngelinux.com | 7/20/2026

0 0 votes
Article Rating
Exit mobile version