After scaling a backend from 3 to 6 instances, the 3 new instances get almost no traffic.
IntermediateTroubleshootingLoad balancers and reverse proxies
Answer
Likely causes → Clients (or an upstream proxy) hold long-lived keep-alive or HTTP/2/gRPC connections to the original instances. An L4 LB balances connections, not requests, so existing connections never move. Least-outstanding-requests or slow start can also skew early traffic.
Diagnose →
# per-target connection counts
aws cloudwatch get-metric-statistics --namespace AWS/ApplicationELB --metric-name RequestCountPerTarget ...
ss -tn state established '( sport = :8080 )' | wc -l # on old vs new instances
Fix → Use an L7 balancer that balances per request (ALB, Envoy, nginx with upstream keepalive pool). For gRPC, use client-side balancing or a proxy that understands HTTP/2 streams, and set max_connection_age on servers so clients reconnect periodically.
Prevent → Cap connection lifetime on servers and verify traffic distribution after every scale event.
More on Load balancers and reverse proxies
nginx returns `502 Bad Gateway` and the error log says `connect() failed (111: Connection refused) while connecting to upstream`.Beginnernginx returns `504 Gateway Time-out` with `upstream timed out (110: Connection timed out) while reading response header from upstream`.BeginnerAn ALB target group shows all targets `unhealthy` with `Health checks failed with these codes: [404]`.BeginnerAn ALB returns sporadic `502`s, and access logs show `elb_status_code=502` with `target_status_code=-`. Load is low.Intermediatenginx logs `upstream prematurely closed connection while reading response header from upstream`.Intermediatenginx error log shows `no live upstreams while connecting to upstream` and every request gets 502.Intermediate