Optimizing TCP Stack Parameters for High-Performance Servers

Optimizing TCP Stack Parameters for High-Performance Servers

Default TCP stack settings are conservative, optimized for compatibility rather than performance. Tuning kernel parameters for your specific workload can dramatically improve throughput, connection handling capacity, and latency on high-traffic servers.

Key Parameters to Tune

Increase net.core.somaxconn and net.ipv4.tcp_max_syn_backlog to handle connection bursts without dropping SYN packets. For servers behind load balancers, these values may need to be several thousand to accommodate simultaneous new connections during traffic spikes.

TCP window scaling and buffer sizes (net.ipv4.tcp_rmem and net.ipv4.tcp_wmem) control how much data can be in flight between sender and receiver. For high-bandwidth, high-latency links, increasing these values from defaults allows the connection to fully utilize available bandwidth.

Enable tcp_tw_reuse to allow reuse of TIME_WAIT sockets for new connections to the same destination. On busy web servers and reverse proxies, thousands of sockets in TIME_WAIT can exhaust ephemeral ports, causing connection failures.

Back to Blog