Interview Prep/Linux/Logs, Limits & High-Traffic Tuning

What TCP keepalive settings matter for long-lived connections through NAT/LBs?

AdvancedProductionLogs, Limits & High-Traffic Tuning
Answer

Cloud NAT gateways and load balancers drop idle flows silently (AWS NAT Gateway after 350 s idle; ALB/NLB have their own idle timeouts). The Linux default net.ipv4.tcp_keepalive_time=7200 (2 hours) is far too long, so idle DB connections appear alive but are dead. Lower it (e.g. 300 s with tcp_keepalive_intvl=30, tcp_keepalive_probes=5), and make sure the app enables SO_KEEPALIVE (most DB drivers have an option) or uses application-level pings.

All Linux questions Roadmap: Linux

More on Logs, Limits & High-Traffic Tuning