Optimizing TCP Connection Concurrency with net.core.somaxconn

Performance Tuning & Kernel Parameters (Sysctl)

Optimizing TCP Connection Concurrency with net.core.somaxconn

🧩 The Challenge

Applications under heavy load frequently experience connection reset errors because the default queue size for incoming TCP connections is too small to handle rapid spikes.

💡 The Fix

Increase the kernel limit for the maximum number of queued connections to allow the listener socket to buffer more pending connections before rejecting them.

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

The somaxconn parameter defines the maximum length of the listen queue for accepting new connections; raising this value prevents packet drops during traffic bursts.

🚀 Pro-Tip: Verify your current queue drops by running netstat -s | grep -i listen to see if connections are being ignored by the kernel.

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

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted