Stackbook Logo
distribution-communicationestablished · medium operational burden

Load Balancing Algorithms

Also known as: lb-algorithms, round-robin, least-connections, consistent-hashing-lb, weighted

Intent

Choose the right load balancing algorithm: round-robin, least connections, least latency, consistent hashing — trade-offs for latency, distribution, and session affinity.

Problem

Default round-robin ignores load, latency, and session needs. Wrong algorithm = uneven load, high latency, broken sessions.

Forces

  • Distribution: even vs weighted vs locality-aware
  • Latency: route to fastest vs simplest algorithm
  • Session affinity: sticky sessions vs stateless
  • Health awareness: avoid unhealthy instances

Solution

✓ When to Use

  • Any service with multiple instances
  • Heterogeneous fleet (different instance types)
  • Session affinity needed (legacy apps)
  • Latency-sensitive user-facing services

✗ When Not to Use

  • Single instance
  • Stateless, homogeneous, low scale (round-robin fine)

Pros

  • +Right algorithm = even load, low latency, high availability
  • +Health awareness = automatic failover
  • +Session affinity = legacy app support

Cons

  • Complexity: algorithm choice, tuning, monitoring
  • Session affinity = uneven load, failover complexity
  • Latency-aware: oscillation, noise sensitivity

Cost Profile

Infrastructure

Low (software LB) to High (hardware, global)

Operational

Medium — algorithm tuning, health checks

Cognitive

Low — standard algorithms

Failure Modes

  • Unhealthy instance in pool: errors, latency

  • Sticky session imbalance: one instance overloaded

  • Hash skew: consistent hash → hot instance

  • Health check flapping: instance flaps in/out

  • Split-brain: two LBs, different views

Real-World Examples

Alternatives

  • service-discovery
  • round-robin
  • least-connections
  • consistent-hashing
  • random

Related Patterns

  • service-discovery
  • health-checks
  • circuit-breaker
  • consistent-hashing
  • session-affinity
  • kubernetes-service

Competency Domains

distribution communicationreliability opsscalingeconomics evolutiondeployment