Performance Tuning & Kernel Parameters (Sysctl)
Stop letting your high-traffic web server drop packets with listen backlog tweaks
đź§© The Challenge
You ever see your web server logs reporting connection refused errors even though the app isn’t even touching the CPU limits? I spent half a morning once convinced the app was crashing, only to realize the OS was just throwing away connections because the queue for pending requests was full.
đź’ˇ The Fix
You need to bump up the backlog queue depth so the kernel has a bigger waiting room for incoming connections before they get handed off to your application. This is a life saver during sudden traffic bursts that would otherwise cause dropped connections.
sysctl -w net.core.somaxconn=4096
sysctl -w net.ipv4.tcp_max_syn_backlog=4096
⚙️ Why It Works
Most kernels ship with a default backlog of 128, which is basically an empty parking space for a modern web server. By bumping these values, you’re letting the TCP stack hold onto those pending handshakes long enough for your worker threads to actually wake up and process them.
🚀 Pro-Tip: Don’t forget to also update your web server’s internal config file to match, otherwise, the kernel will just clip the request anyway.
Linux Tips & Tricks | © ngelinux.com | 8/25/2026
