Stop your Linux box from hoarding dead TCP buffers
Performance Tuning & Kernel Parameters (Sysctl)
Stop your Linux box from hoarding dead TCP buffers
🧩 The Challenge
You know that feeling when a high-traffic app suddenly slows to a crawl, and you find thousands of TCP buffers sitting idle, eating up RAM like they’re waiting for a bus that’s never coming? I spent an entire weekend chasing memory leaks in a Python service only to realize the kernel was just being way too lazy about reclaiming memory from idle connections.
💡 The Fix
Crank up the TCP memory pressure settings and tune the autotuning buffers so the kernel actually cleans up after itself instead of waiting until the system is gasping for air. It saves you from random OOM kills when your traffic spikes.
sysctl -w net.ipv4.tcp_rmem='4096 87380 6291456'
sysctl -w net.ipv4.tcp_wmem='4096 16384 4194304'
sysctl -w net.ipv4.tcp_mem='786432 1048576 1572864'
⚙️ Why It Works
By tightening those three values, you force the kernel to stop over-allocating memory for TCP receive and send buffers, which keeps your memory footprint predictable even under heavy load. You’re basically setting hard floors and ceilings that stop the kernel from being too optimistic about available RAM.
🚀 Pro-Tip: Run sysctl -p after tweaking /etc/sysctl.conf to make the changes stick across reboots, or you’ll be right back here after the next power cycle.
Linux Tips & Tricks | © ngelinux.com | 7/19/2026
