How do you troubleshoot intermittent 502 and 504 errors behind a load balancer?
IntermediateProductionLoad Balancing, Proxies & nginx in Production
Answer
502: check backend crashes and restarts, keep-alive mismatch, backend closing connections, TLS mismatch to the target, oversized headers. 504: slow responses beyond the timeout, saturated workers, dependency latency, or target group timeouts. Correlate ALB access logs (target_status_code, target_processing_time, elb_status_code) with app logs.
# elb_status_code=502 and target_status_code=- means target closed or reset connection
More on Load Balancing, Proxies & nginx in Production
How do you choose between ALB, NLB and an nginx or Envoy fleet?IntermediateHow do you tune ALB idle timeout and backend keep-alive to avoid 502s?IntermediateWhich nginx directives matter most for a production reverse proxy?IntermediateHow do you do rate limiting and abuse protection in nginx?IntermediateHow do you achieve zero-downtime configuration reloads in nginx and HAProxy?IntermediateHow would you design a highly available load-balancing tier on-prem or in a colo?Advanced