Stop your server from tanking when the TCP buffer fills up

Performance Tuning & Kernel Parameters (Sysctl)

Stop your server from tanking when the TCP buffer fills up

🧩 The Challenge

Dealing with a high-traffic app where the connection queue just gives up during spikes is soul-crushing. I’ve spent whole afternoons staring at netstat drops because the kernel couldn’t keep up with incoming SYNs.

💡 The Fix

Crank up the net.core.somaxconn parameter to allow a much larger backlog of pending connections. It keeps the box stable when the traffic hits the fan.

sysctl -w net.core.somaxconn=4096
echo "net.core.somaxconn = 4096" >> /etc/sysctl.d/99-performance.conf
sysctl -p /etc/sysctl.d/99-performance.conf

⚙️ Why It Works

Most distros ship with a default of 128, which is basically a rounding error on modern hardware. Bumping this limit lets the kernel hold more handshakes in memory before it starts sending resets to your users.

🚀 Pro-Tip: Check your app’s listen() call too, or the kernel limit won’t actually do anything.

Linux Tips & Tricks | © ngelinux.com | 12/3/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted