Interview Prep/Networking/Load Balancing, Proxies & CDN

Deployments cause 502 errors for a few seconds behind the load balancer. How do you stop that?

IntermediateScenarioLoad Balancing, Proxies & CDN
Answer

Situation read → Targets are being removed while requests are in flight, or new targets get traffic before they are ready.

What I'd do →

  1. Set the target group deregistration delay (default 300s) to cover your longest request: aws elbv2 modify-target-group-attributes --attributes Key=deregistration_delay.timeout_seconds,Value=30
  2. On shutdown handle SIGTERM: stop accepting new work, finish in-flight requests, then exit
  3. In Kubernetes add a preStop sleep and a readiness probe
  4. Ensure the app keep-alive timeout is longer than the LB idle timeout to avoid reused connection resets

Why → 502s on deploy are race conditions between LB state and app lifecycle.

Interview tip → Mention the keep-alive mismatch as the most common hidden cause.

All Networking questions Roadmap: Networking for DevOps

More on Load Balancing, Proxies & CDN