A user reports that long-lived WebSocket connections drop after 60 seconds behind your ALB. What do you change?
IntermediateScenarioLoad Balancing, Proxies & CDN
Answer
Situation read → The ALB idle timeout default is 60 seconds and WebSocket idle periods hit it.
What I'd do →
- Raise the ALB idle timeout:
aws elbv2 modify-load-balancer-attributes --load-balancer-arn <arn> --attributes Key=idle_timeout.timeout_seconds,Value=3600 - Send application-level pings every 20 to 30 seconds
- Make sure backend and proxies in between (Nginx
proxy_read_timeout) allow the same duration - Reconnect with backoff on the client
Why → The weakest timeout in the chain wins; every hop needs a matching value.
Interview tip → Say the keepalive from the app must be shorter than the LB idle timeout.
More on Load Balancing, Proxies & CDN
What is the difference between a Layer 4 and a Layer 7 load balancer?BeginnerWhen do you choose an ALB and when an NLB in AWS?BeginnerForward proxy versus reverse proxy: what is the difference?BeginnerHow do health checks work on a load balancer and what makes a good one?BeginnerWhat are sticky sessions and why would you avoid them?BeginnerWhat does a CDN do and when does it help?Beginner