Reading preferences
Concept

Load Balancing

Distribute requests across healthy service instances.

system design, load balancing, availability

Why share the work?

Imagine one school office receiving every timetable question. When many students arrive together, several helpers can share the queue. A load balancer is a traffic director: it selects a service instance, meaning one running copy of a service, for an incoming request. It can spread work and avoid sending new traffic to a copy known to be unhealthy.

School portal: read requests

  1. Two healthy portal instances can answer timetable requests using shared data.
  2. The balancer sends one request to A and a later request to B.
  3. A health check reports B unhealthy, so new requests go to A. Existing requests to B might still fail; A must have enough capacity.

See the reasoning

Route around an unhealthy instance

Follow new portal requests as health changes. This is a prepared demonstration, not live code execution.

First request

Illustrative routing
  1. Instance AHealthy; receives request 1Current focus
  2. Instance BHealthy

The balancer selects A.

Photo uploads: a different shape of work

For a hypothetical photo app, the balancer routes uploads to healthy upload instances. Large uploads occupy connections longer than small reads, so simple round-robin counts may distribute work unevenly. An interrupted upload may need a resumable protocol and shared durable storage; switching instances alone does not resume it.

Costs and failure

Health checks can be late or wrong. A balancer and its network path also need capacity and resilience, and a shared database can still be a bottleneck. Session affinity may keep a client on one instance, but makes failover and distribution harder; shared or stateless session handling is another option.

Reflect on the concept

Four fixed questions to reinforce the reasoning. Answers are not saved or scored.

1. Why place a load balancer before service instances?
2. What can a health check help a balancer do?
3. What matters when an upload is interrupted?
4. What remains a possible shared bottleneck?

References and further reading