Stop your massive write buffers from causing lag spikes

Performance Tuning & Kernel Parameters (Sysctl)

Stop your massive write buffers from causing lag spikes

🧩 The Challenge

You know that feeling when your web server suddenly hitches for a few seconds during a heavy log rotation or a database dump? It’s almost always because the kernel decided to dump a massive wall of dirty pages to disk all at once, turning your snappy production server into a slideshow.

💡 The Fix

Tweak your dirty background ratios so the kernel starts trickling those writes to disk way earlier instead of waiting for a total logjam. This keeps your I/O pressure smooth and avoids those terrifying latency spikes.

sysctl -w vm.dirty_background_bytes=67108864
sysctl -w vm.dirty_bytes=268435456

⚙️ Why It Works

Setting these values forces the kernel to start background writeback once you hit 64MB of dirty memory and blocks processes if they reach 256MB. It keeps the commit pipeline moving steadily so the disk controller doesn’t get overwhelmed by a sudden deluge of data.

🚀 Pro-Tip: Run these through sysctl -p after adding them to /etc/sysctl.d/99-performance.conf so they actually survive a reboot.

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

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted