Networking fundamentals · Lesson 6 of 9 · 4 min read
AWS load balancers in practice
Choosing a load balancer
| ALB | NLB | GWLB | |
|---|---|---|---|
| Layer | 7 (HTTP/HTTPS, gRPC, WebSockets) | 4 (TCP, UDP, TLS) | 3 (IP packets, GENEVE) |
| Routing | Host, path, header, query, method, source IP rules; weighted target groups | Port-based | Transparent insertion of appliances |
| Targets | Instances, IPs, Lambda | Instances, IPs, ALB | Appliances |
| Static IP | No (DNS name; IPs change) | Yes — one per AZ, or your Elastic IPs | — |
| Client IP | X-Forwarded-For |
Preserved (or Proxy Protocol v2) | Preserved |
| Extras | WAF, OIDC/Cognito auth, redirects, fixed responses, sticky cookies | Very high throughput, ultra-low latency, PrivateLink services | Firewalls/IDS fleets |
The Classic Load Balancer is legacy. Rules of thumb: HTTP apps → ALB; non-HTTP TCP/UDP, static IPs, extreme performance, or exposing via PrivateLink → NLB.
Enlarge diagram
Swipe sideways to see all of it, or tap to open it full screen.
Settings that cause real incidents
- Health checks — path, port, protocol, success codes (
200by default; an app that redirects/to/loginwith 302 will fail), interval, thresholds. The target's security group must allow the LB (reference the LB's SG). "Health checks fail but the app works when I curl it on the instance" → SG, wrong port/path, expected code, or the app binds to 127.0.0.1. - Idle timeout — ALB default 60 s. Requests longer than that get 504 unless raised; the backend's keep-alive timeout must be longer than the ALB idle timeout, otherwise the app closes connections the ALB still reuses → intermittent 502.
- Deregistration delay (connection draining) — default 300 s; tune for rollout speed.
- Cross-zone load balancing — on by default for ALB, off by default for NLB (inter-AZ data charges apply when enabled on NLB). Uneven targets per AZ + cross-zone off = uneven load.
- Slow start (ALB) — ramp traffic to new targets gradually.
- Target type —
iptargets (pods directly, with the AWS LB Controller) vsinstance(NodePort hop). - ELB vs target 5xx metrics —
HTTPCode_ELB_5XX_Count(the LB generated it: no healthy targets, timeouts, connection errors) vsHTTPCode_Target_5XX_Count(your app returned it). This tells you instantly who's at fault.
Enlarge diagram
Swipe sideways to see all of it, or tap to open it full screen.
Enlarge diagram
Swipe sideways to see all of it, or tap to open it full screen.