Stale load reports
Detect: Requests accumulate on a replica that appears idle.
Recover: Expire capacity advertisements and use conservative admission.
Distribute inference work using token demand, queue pressure, capability, and cache locality instead of treating all requests as equal.
LLM load balancing assigns requests to compatible inference replicas or provider deployments. Request count is an inadequate load signal: a short classification and a long document analysis consume very different prefill, decoding, and key-value cache resources. A useful balancer estimates work while preserving fairness and admission limits.
The routing unit is normally a complete generation. Moving an active sequence requires engine-specific state transfer and should not be assumed. Prefix-aware routing may improve reuse, but excessive affinity can overload one replica while others remain idle. Balance locality against queueing delay using measured workload behavior.
Start by comparing round-robin routing with observed prompt lengths and completion times.
Production adds bounded queues, token-aware concurrency, cancellation propagation, and separate interactive and background capacity.
At scale, route across failure domains, account for heterogeneous accelerators, and test hot-prefix traffic and tenant fairness under sustained overload.
Estimates input tokens, output budget, required model, and deadline.
Publishes available model versions, health, and capacity classes.
Combines queue delay, token pressure, fairness, and optional prefix locality.
Bounds waiting work and rejects requests that cannot meet their deadlines.
Report active tokens, cache pressure, completion, and cancellation.
flowchart LR
R["Incoming generation"] --> E["Token and deadline estimate"]
E --> Q["Fair admission queue"]
Q --> B["Replica selection"]
B --> A["Replica A short queue"]
B --> C["Replica B warm prefix"]
B --> D["Replica C long contexts"]
A --> M["Load feedback"]
C --> M
D --> M
M --> BResolve model compatibility and separate latency-sensitive traffic from deferred jobs.
Count prompt tokens and use an explicit output ceiling to approximate sequence cost.
Choose among healthy compatible replicas using current queue and memory pressure.
Reserve capacity or return a clear overload response before an unbounded queue forms.
Keep the sequence on its chosen replica and propagate caller cancellation promptly.
Compare predicted and actual cost so future routing reflects real request distributions.
Enterprise SaaS · Illustrative enterprise scenario, not a reported customer outcome.
A document platform shares model capacity between interactive drafting and large workspace summaries.
Long summary requests occupy cache and delay short user edits.
Protect interactive response time while using spare capacity for background work.
The gateway maintains separate queues and routes with token budgets and per-tenant fairness.
When one replica reports cache exhaustion, new long requests defer while active sequences finish safely.
Evaluate tail latency by workload class, queue age, and accelerator utilization together; average throughput can hide interactive starvation.
| Decision | Benefit | Cost |
|---|---|---|
| Token-aware scheduling | Better reflects heterogeneous work. | Requires estimation and live engine metrics. |
| Prefix affinity | Can reduce repeated prefill work. | Creates hotspots if many requests share one prefix. |
| Separate pools | Protects critical response budgets. | May leave capacity idle during uneven demand. |
Detect: Requests accumulate on a replica that appears idle.
Recover: Expire capacity advertisements and use conservative admission.
Detect: Background queue age rises despite available overall throughput.
Recover: Reserve a minimum share and age waiting jobs fairly.
Include token and memory pressure in decisions.
Return bounded retry guidance or defer through a durable queue.
Release reservations and stop abandoned generations.