Load balancing basics
Why load balance?
- Distribute traffic across multiple backends
- Improve availability (health checks, failover)
- Enable horizontal scaling
Common types
- L4 (transport): TCP/UDP forwarding (fast, less visibility)
- L7 (application): HTTP routing, headers, TLS termination
Algorithms
- Round-robin
- Least connections
- Hash-based (source IP / cookie / header)
Health checks
Key for reliability:
- TCP connect checks (L4)
- HTTP endpoint checks (L7) like
/healthz
Sticky sessions
Sometimes required for stateful apps, but prefer stateless backends + shared session store.
- Nginx / HAProxy (software)
- Cloud LBs (ALB/NLB/etc.)