Video in progress
One of the pods got slow (GC, a noisy neighbor), but the load balancer still sends it an equal share of traffic. Which balancing handles this better?
Round robin doesn't know the state of the backend. Least request, especially power of two choices (pick two random backends and take the less busy one), and latency-aware EWMA send less to a slow pod on their own; outlier detection temporarily ejects the bad one.
📖 Answer
If one of 10 pods is 5 times slower, with round robin 10% of requests are slow and p99 is set by that pod. The health check doesn't see it: the pod is alive, just slow.
Least request / least connections. It looks at the number of active requests on each backend. On a slow pod requests stay longer, their number grows, so it gets less. The problem: if all LB instances pick the "emptiest" pod at the same moment, a wave of traffic hits it (herd).
Power of two choices (P2C). Take two random backends and pick the less busy one. It sounds simple, but it sharply reduces the worst load and doesn't cause a herd, so it works well even when the LBs don't know about each other. Envoy's LEAST_REQUEST balancer works this way by default (choice_count: 2).
EWMA. Each backend's recent response times are tracked with an exponential average, and "active requests × latency" is used as the cost. Linkerd and Finagle use this together with P2C. A slowed pod gets almost no traffic within a few seconds, and traffic comes back gradually as it recovers.
Outlier detection. If consecutive 5xx responses or latency go over a threshold, the backend is temporarily removed from the pool and later put back as a trial. It's the host-level variant of a circuit breaker.
# Envoy cluster (shortened)
lb_policy: LEAST_REQUEST
outlier_detection:
consecutive_5xx: 5
interval: 10s
base_ejection_time: 30s
max_ejection_percent: 30
max_ejection_percent matters: if the problem is shared (say, the DB is slow), the LB must not eject every pod.
Spring Cloud LoadBalancer gives you round robin by default on the client side. If you have a mesh or Envoy, it's easier to hand this decision to that layer, so you don't have to configure it separately in every service.
Sign up to mark studied questions and save your progress.