Load Balancing Algorithms
What you'll learn: How to configure different load balancing strategies in a service mesh to optimize traffic distribution across your service instances.
The Core Idea
When traffic arrives at a service with multiple replicas, the service mesh must decide which instance receives each request. Load balancing algorithms are the decision-making strategies that determine this distribution. Choosing the right algorithm ensures efficient resource utilization, minimizes latency, and prevents instance overload.
Think of it like a restaurant host seating customers: round-robin rotates tables evenly, least-request seats at the table with fewest diners, and consistent hash assigns the same customer to their preferred table each time.
Common Strategies
Round-Robin
The default for most meshes. Each request goes to the next instance in sequence. Simple and fair, but doesn't account for instance load or request complexity. Best when all instances are equally capable and requests are similar in cost.
Least-Request (Least-Connections)
Routes traffic to the instance currently handling the fewest active requests. More intelligent than round-robin because it adapts to real-time load. Ideal when request processing times vary significantly or instances have different capacities.
Consistent Hash
Uses a hash function based on request attributes (headers, source IP, cookies) to deterministically route requests to the same instance. Critical for session affinity or when instances maintain local caches. The "consistent" part means minimal disruption when instances are added or removed.
Configuration Context
In your service mesh, you configure these algorithms through DestinationRules alongside your connection pool settings and circuit breakers. The choice affects how traffic splitting, canary deployments, and retry policies behave—your algorithm must complement your overall traffic management strategy.
Key Takeaway: Load balancing algorithms determine how requests distribute across service instances; choose round-robin for simplicity, least-request for adaptive balancing, or consistent hash when request affinity matters.