Stop your server from bottlenecking on high concurrency
Performance Tuning & Kernel Parameters (Sysctl)
Stop your server from bottlenecking on high concurrency
🧩 The Challenge
You finally moved your microservice to production, but the connection pool is hitting a wall while the CPU sits at a boring 20 percent. Turns out, the default port range for ephemeral connections is way too small for a busy API.
💡 The Fix
Crank up the local port range and reuse those sockets faster so you don’t run out of available ports during a minor traffic spike. This prevents that annoying “cannot assign requested address” error that ruins your morning.
sysctl -w net.ipv4.ip_local_port_range="1024 65535"
sysctl -w net.ipv4.tcp_tw_reuse=1
⚙️ Why It Works
Expanding the port range gives your apps more room to breathe, while enabling TW reuse lets the kernel recycle sockets in a TIME_WAIT state that would otherwise sit there and rot for minutes.
🚀 Pro-Tip: Verify your changes stick after a reboot by dropping these settings into /etc/sysctl.d/99-networking.conf instead of just running the command.
Linux Tips & Tricks | © ngelinux.com | 10/11/2026
