Stop your TCP stack from dropping connections during a traffic spike

Performance Tuning & Kernel Parameters (Sysctl)

Stop your TCP stack from dropping connections during a traffic spike

🧩 The Challenge

You’re staring at your logs and see a sea of “connection reset by peer” errors even though your app isn’t actually overloaded. It turns out the listen backlog on your socket is just too small to handle the sudden burst of incoming SYNs.

💡 The Fix

Crank up the listen backlog and the maximum number of half-open connections in sysctl. This gives the kernel some breathing room to actually finish handshakes before your users get booted.

sysctl -w net.core.somaxconn=4096
sysctl -w net.ipv4.tcp_max_syn_backlog=4096

⚙️ Why It Works

By default, these limits are often set for servers from the late 90s, so they get overwhelmed the second a few hundred people hit your API at once. Increasing them keeps the kernel from just slamming the door on incoming requests while the application process is still busy.

🚀 Pro-Tip: Check your app’s listen queue usage with ss -lnt to see if your current backlog is actually hitting the limit.

Linux Tips & Tricks | © ngelinux.com | 10/10/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted