Stop letting your web servers choke on half-open TCP connections

Performance Tuning & Kernel Parameters (Sysctl)

Stop letting your web servers choke on half-open TCP connections

🧩 The Challenge

Dealing with a massive flood of incoming requests and watching your server start dropping packets because the backlog is full of garbage is a nightmare. I spent an entire weekend chasing “connection reset by peer” errors just to realize the default listen queue was laughably small for the traffic we were pushing.

💡 The Fix

Crank up the net.core.somaxconn and tcp_max_syn_backlog values to give your listening sockets some breathing room when a spike hits. It’s the easiest way to stop connections from being rejected before your app even sees them.

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

⚙️ Why It Works

Increasing these settings expands the size of the kernel-side queue for pending connections, preventing the dreaded SYN overflow that happens when the handshake can’t finish fast enough. And yeah, make sure you bump these in /etc/sysctl.conf so they actually stick after a reboot.

🚀 Pro-Tip: Check netstat -s | grep “SYNs to LISTEN sockets dropped” to see if you’re actually losing connections before you start tuning.

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

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted