AlgoViz

Load balancing with unequal work

medium 7 min

Routing algorithms choose a target at a particular granularity.

Video lesson · Chapter 1 of 4

Equal request counts, unequal queues

0:00 / 2:08

Theory

Read or listen first. About 2 min.

What it is

Routing algorithms choose a target at a particular granularity. A transport balancer generally selects a backend for a connection, while an application proxy can route requests. Round robin balances selections, weights describe intended proportions, and least-connections observes concurrent connections. None of these alone tells you exactly how much CPU a particular request will cost.

Why it exists

A service mixes long exports with short reads. Backends get roughly equal numbers of requests but one develops a long queue. Inspect active work and service time by class. A long-lived multiplexed connection can carry many simultaneous requests, making connection count a poor proxy. Choose an observable signal aligned with actual occupancy.

If outstanding work is balanced, compare host-specific CPU limits, data locality and dependency waits.

Equal request counts, unequal queues

Traffic distributor → Worker pool (select worker). Long requests → Worker pool (occupy worker slots)
Traffic distributor → Worker pool (select worker). Long requests → Worker pool (occupy worker slots)

Inside this chapter

L4 (Transport) Load Balancing (NAT, DSR)
A transport balancer forwards connections. NAT changes addresses while direct server return can send responses on a different path. Observe both directions when interpreting traffic counts.
L7 (Application) Load Balancing (Reverse Proxy)
An application proxy can route by HTTP attributes and choose backends per request. It also introduces its own queues, upstream pool, timeout configuration and termination behavior.
Algorithms: Round Robin, Least Connections
Round robin rotates selections; least-connections uses current connections. Unequal work per connection makes either imperfect, especially with multiplexing or long-lived streams.
Consistent Hashing for caches
Consistent hashing limits key movement when membership changes. Skewed key frequency still creates hot owners, and movement can produce a temporary cold-cache wave.
Health Checks: Active vs Passive
Active probes send synthetic checks. Passive checks infer health from real traffic. Neither alone guarantees that every customer journey succeeds for every request class.
Session Persistence (Sticky Sessions)
Sticky routing preserves affinity through a cookie or selection rule. It can concentrate traffic or hide missing shared state. Decide how affinity behaves when an owner disappears.
Weighted Load Balancing
Weights express intended capacity or exposure over many selections. Compare actual completed work against weights because persistent connections and small cohorts can distort the observed split.
Global Server Load Balancing (GSLB)
Global routing directs users among regions using signals such as health and location. Cache and connection lifetimes can delay convergence after health changes.

How it works

Step through the idea, or press Play.

Step 1 of 4

Select an endpoint. The distributor considers eligible backends under its routing policy.

Understand it

Worked incident

Equal request counts, unequal queues

ObservationLongest worker queue (requests)Interpretation
Baseline2Similar service times keep queues short.
Incident45Long exports pile up on a worker despite evenly distributed request counts.
After intervention5Isolate exports or route by outstanding work. Compare the maximum queue and tail delay.
Illustrative measurements from the same workload at three checkpoints.

Choose the next investigation

If outstanding work is balanced, compare host-specific CPU limits, data locality and dependency waits.

Summary

The whole topic in one minute.

Multiplexed or differently weighted requests break that assumption. Count the scarce execution slots when possible.

If outstanding work is balanced, compare host-specific CPU limits, data locality and dependency waits.

Sources