What are common Load Balancing Strategies?
Topic: microservices, Infrastructure. Level: Intermediate.
Answer
- **Round Robin**: rotate evenly; simple, ignores load.
- **Least Connections**: send to the instance with fewest active requests; good for uneven request durations.
- **Weighted**: bias toward more capable instances (or canary weights).
- **Least Response Time / EWMA**: favor the fastest-responding instances.
- **Consistent Hashing**: map a key (user/session) to the same instance for cache locality/sticky sessions with minimal reshuffling when instances change.
Layer 4 (TCP) vs Layer 7 (HTTP-aware, can route by path/header). Pair with health checks so only healthy instances receive traffic.
```text
Round Robin -> A,B,C,A,B,C (even, load-blind)
Least Connections -> pick instance with min in-flight requests
Weighted -> A:5 B:3 C:2 (capacity/canary bias)
Consistent Hash -> hash(userId) -> same instance (cache/session affinity)
```