Skip to main content

Connection Pooling - in Depth

· 3 min read
Abhishek Tripathi
Curiosity brings awareness.

Here’s a Markdown table that maps real-life reverse proxy scenarios to recommended TCP tuning parameters for optimal performance and security:

Legend (Quick Reference)

ParameterPurpose
tcp_fin_timeoutHow long to keep closing connection in FIN state.
tcp_keepalive_timeIdle time before sending first keep-alive probe.
tcp_keepalive_intvlInterval between successive keep-alive probes.
tcp_keepalive_probesNumber of probes before dropping connection.
tcp_retries2Max TCP retransmissions before giving up.

TCP Tuning Recommendations for Reverse Proxy - Real Life Scenarios

Scenariotcp_fin_timeouttcp_keepalive_timetcp_keepalive_intvltcp_keepalive_probestcp_retries2Reasoning & Trade-offs
Public API Gateway (high concurrent clients)15301035Quick cleanup of dead/idle connections to save resources, while allowing short keep-alives for API clients.
Internal microservices (low latency, stable network)10602033Fast connection recycling, rare need for keep-alives due to low latency, prioritizing efficiency.
Mobile-heavy client traffic (prone to network drops)301202057More lenient timeouts to account for intermittent mobile network instability; avoid prematurely dropping clients.
WebSocket / long-lived connections (chat apps, gaming)603006058Allow long idle connections; keep-alives to detect dead connections without cutting active clients abruptly.
DDoS-prone public proxy (security-focused)530523Aggressive timeouts to prevent resource exhaustion; fast cleanup of potentially malicious connections.
IoT Device Communication (sporadic, unstable)301803046Longer keep-alives to maintain connection with low-power devices, balanced with cleanup to avoid idle hangs.
Slow clients behind proxies (corporate clients, satellite)201503046Moderate timeouts to handle slow networks without dropping legitimate users.

⚙️ Notes:

  • Lower timeouts: Free up resources quickly, but risk dropping slow/legit connections.
  • Higher timeouts: Improve user experience over slow networks but consume more resources.
  • Keep-alive settings: Essential for long-lived or idle connections to detect dead peers.
  • Retries: Trade-off between network resilience and resource use.

If you want, I can prepare a sysctl.conf file snippet based on any of these scenarios for direct use. Let me know! 🚀


source: https://github.com/brettwooldridge/HikariCP/wiki/Down-the-Rabbit-Hole