learn/System Design/Load Balancing
ScalingCore interactive

Load Balancing

Spread traffic across servers, no single hotspot.

load_balancer
clients
LB

Requests spread across the pool — no single server becomes a hotspot.

How it works

A load balancer sits in front of a server pool and distributes incoming requests so no one machine is overwhelmed. Strategies range from round-robin to least-connections to weighted routing, with health checks that pull dead nodes out of rotation.

Mental models

  • Round-robin, least-connections, IP-hash, and weighted are the staples.
  • Health checks + automatic failover keep traffic off dead servers.
  • L4 balances on IP/port (fast, just forwards packets); L7 reads HTTP paths, headers, and cookies to route smarter.
  • SSL termination at the LB means backend servers skip the expensive decrypt/encrypt work.
  • Horizontal scaling only works if servers are stateless — sessions belong in a shared store, not local memory.

Common pitfalls

  • The load balancer itself is a new single point of failure — pair it with a standby in active-passive or active-active mode.
  • Sticky sessions reintroduce state into a 'stateless' fleet; prefer a centralized session store (Redis, DB) instead.
  • An underprovisioned or misconfigured LB becomes the bottleneck it was meant to prevent.

Reach for it when

  • Horizontal scaling
  • Zero-downtime deploys
  • Geographic routing