Slides · Inference engineering

Production operations: capacity, scaling and failure

Production operations: capacity, scaling and failure

How many replicas, what makes them scale, how requests find them, how to measure without fooling yourself, and what to do when it breaks.

By the end you can plan replicas from peak load and check the plan against the cache, pick autoscaling signals that lead, route and retry safely, design an honest benchmark, and work through a latency regression.

Diagram

The shape of a serving platform

Diagram: Requests pass a gateway and a router into replica pools, which emit metrics and traces that an autoscaler reads to add or remove replicas.

Clients

Gateway: auth, quotas

Router

Pool A: engine, GPUs

Pool B: other model

Metrics and traces

Autoscaler

Diagram summary: Requests pass a gateway and a router into replica pools, which emit metrics and traces that an autoscaler reads to add or remove replicas. The sketch leaves out weight loading from object storage and any external API used as overflow.

Concept

Set targets per traffic class

Chat, agent tool loops and batch jobs want different things, so each class gets its own targets.

  • Time to first token (TTFT) at p95 and p99.
  • Inter-token latency (ITL) at p95.
  • Error rate.
  • Goodput: the rate of requests per second that meet both latency targets. The matching share, goodput divided by all requests, is the fraction of users served well.

Google’s SRE book (monitoring chapter) says monitoring has to answer what is broken and why, and spend more effort on symptoms than on causes. Its four golden signals are latency, traffic, errors and saturation, and it asks that every page need human judgment.

Source1 Chapter 6: Monitoring Distributed Systems

Compare

Page on symptoms, dashboard the causes

Page on (symptoms)Dashboard (causes)
TTFT and ITL percentiles against targetRunning and waiting requests, queue time
Error rateKV-cache utilization, prefix-cache hit rate
GoodputPreemptions, batch size, token rates in and out
Speculative acceptance, GPU throttling, finish reasons

The vLLM metrics design page (dated 12 October 2026) shows, among others, these names: vllm:time_to_first_token_seconds, vllm:inter_token_latency_seconds, vllm:kv_cache_usage_perc, vllm:prefix_cache_hits, vllm:prefix_cache_queries, vllm:num_requests_running, vllm:prompt_tokens_total, vllm:generation_tokens_total and vllm:request_success_total (labelled finished_reason in its example). The same page says its naming may be revisited and shows request_success with and without _total, so read your own engine’s /metrics output.

Sources2 Metrics design (vLLM documentation)1 Chapter 6: Monitoring Distributed Systems

Process

The capacity method

  1. Describe the traffic: peak and daily shape of requests per second, input and output token distributions at p50 and p95, and how much prefix is shared.
  2. Benchmark one replica on that distribution at the latency target. Its capacity is the goodput it sustains, not its peak tokens per second.
  3. replicas=peak loadper-replica capacity×target utilization\text{replicas} = \dfrac{\text{peak load}}{\text{per-replica capacity} \times \text{target utilization}}, rounded up, plus spares for failures and deploys. A target of 0.6 to 0.7 is a judgment; tune it to burstiness and cold-start time.
  4. Cross-check with Little’s law and the cache: requests in flight equal arrival rate times time in system, and they must fit in the KV pool.

Worked example

Worked: 30 requests per second

All figures illustrative. Peak 30 requests per second, 1,200 input and 250 output tokens each. One replica (a 70B model on four GPUs) sustains 2,000 output tokens per second at target. Utilization target 0.65.

StepArithmeticResult
Peak output rate30×25030 \times 2507,500 tokens/s
Raw replicas7,500/2,0007{,}500 / 2{,}0003.75
With margin3.75/0.653.75 / 0.655.8, so 6
Plus one spare6+16 + 17 replicas, 28 GPUs
Time in system0.5 s+249×0.03 s0.5\ \text{s} + 249 \times 0.03\ \text{s}about 8 s
In flight (Little’s law)30×830 \times 8about 240
Per serving replica240/6240 / 640

A replica with a 400,000-token pool holds about 275 sequences of 1,450 tokens (1,200 + 250), so 40 sits well inside. Had the figure been 300, the cache would bind before compute.

Math

Little’s law for a serving pool

in_flight=arrival_rate×time_in_system\text{in\_flight} = \text{arrival\_rate} \times \text{time\_in\_system}per_replica=in_flightserving_replicas\text{per\_replica} = \frac{\text{in\_flight}}{\text{serving\_replicas}}fits  ⟺  per_replica≤sequences_the_pool_holds\text{fits} \iff \text{per\_replica} \le \text{sequences\_the\_pool\_holds}
SymbolMeaning
arrival_rate\text{arrival\_rate}Requests per second at the peak being planned for
time_in_system\text{time\_in\_system}Seconds from admission to the last token, including queueing
sequences_the_pool_holds\text{sequences\_the\_pool\_holds}KV pool tokens divided by tokens in a typical sequence

The law is an average-over-time identity for a stable system. Use the peak rate to check the peak, and a pessimistic time in system for tail checks.

Check yourself

Check: replicas, then the cache

Provenance: Generated practice.

Peak is 14 requests per second with 600 input and 180 output tokens. A replica sustains 1,500 output tokens per second at target, utilization target is 0.6, and one spare is kept. A request takes about 0.5 s to the first token and then 30 ms per token. Each replica’s pool holds 25 sequences of the typical size. How many replicas does throughput ask for, and does the cache agree?

Answer

Output rate: 14×180=2,52014 \times 180 = 2{,}520 tokens/s. 2,520/1,500=1.682{,}520 / 1{,}500 = 1.68; /0.6=2.8/ 0.6 = 2.8, so 3 serving replicas, 4 with the spare. Time in system: 0.5+179×0.03=5.870.5 + 179 \times 0.03 = 5.87 s, so 14×5.87=8214 \times 5.87 = 82 in flight, 27.4 per replica across 3. That exceeds 25, so the cache binds: 82/25=3.382 / 25 = 3.3, so 4 serving replicas are needed, 5 with the spare. The plan takes the larger of the two answers.

Compare

Which signal to scale on

SignalLeads or lagsWhy
Waiting requests or queue depth per replicaLeadsRequests queue before anyone sees slow answers
KV-cache utilization near its limitLeadsA full pool means queueing and eviction are next
Running sequences against the benchmarked limitLeadsCompares load with measured capacity
TTFT p95 approaching targetLeads, lateA direct symptom that moves as queues build
GPU utilization aloneMisleadsA busy GPU can be saturated or redoing evicted work, so it does not say whether another replica helps
CPU utilizationMisleadsGPU work is not visible in it

Scale on a signal that moves before users feel it.

Diagram

What a new replica must do before it helps

Diagram: A replica is useful only after it pulls its image, loads its weights, captures CUDA graphs and warms up, and the steps run in sequence.

Scale-up signal

Pull container image

Load weights

Capture CUDA graphs

Warm up

Ready for traffic

Diagram summary: A replica is useful only after it pulls its image, loads its weights, captures CUDA graphs and warms up, and the steps run in sequence. Weight loading scales with model size and storage speed, which is why scaling must start on a leading signal.

Source3 Loading models with Run:ai Model Streamer (vLLM documentation)

Worked example

Worked: weight loading and the ramp

Loading time is bytes over rate. For 140 GB of weights:

Load rateArithmeticTime
2 GB/s140/2140 / 270 s
5 GB/s140/5140 / 528 s
10 GB/s140/10140 / 1014 s

The vLLM page for the Run:ai Model Streamer (dated 15 October 2026) describes reading tensors concurrently while streaming them to GPU memory, from a local path or object storage, and says its distributed option can significantly improve load times from object storage or fast network file shares. Other levers: pre-pulled images, weights cached on node disks, warm pools. The page covers weight streaming only; the five-step start-up sequence and its ordering are the course’s reasoning.

Now a ramp. Traffic doubles from 30 to 60 requests per second. Each replica serves 2,000/250=82{,}000 / 250 = 8 requests per second at target, so 6 serving replicas serve 48. A new replica needs 3 minutes. For 180 s the shortfall of 12 requests per second queues 2,160 requests. Arrivals stay at 60 per second, so with six replicas serving 48 the queue keeps growing by 12 per second. One extra replica lifts capacity to 56, still below 60, so the queue still grows, by 4 per second. Serving 60 per second at 8 per replica takes 60/8=7.560 / 8 = 7.5, so at least 8 replicas even with no margin (capacity 64, surplus 4 per second, so the 2,160 backlog takes 2,160/4=5402{,}160 / 4 = 540 s to clear), and 12 at the 0.65 target (60/8/0.65=11.560 / 8 / 0.65 = 11.5; capacity 96, surplus 36, backlog cleared in 2,160/36=602{,}160 / 36 = 60 s once all are ready). One extra replica is nowhere near enough.

Source3 Loading models with Run:ai Model Streamer (vLLM documentation)

Concept

Scale up fast, scale down slowly, and drain

  • Adding capacity late hurts users now; removing it late costs a little money. The asymmetry argues for quick scale-up and a cool-down before scale-in.
  • Drain before terminating: a replica marked for removal takes no new requests and keeps running until its open streams end or hit the longest generation time you allow. With a 60 s cap, the drain window is at least 60 s, so the cool-down and the platform’s termination grace period must both be longer. Cutting a stream at once discards work already done and leaves the user with half an answer.
  • Scale-to-zero suits rarely used models only when users can tolerate the cold start. Otherwise share GPUs, or serve many adapters on one base (lesson 5).
  • For a known ramp, scale ahead on a schedule instead of waiting for a signal.

Check yourself

Check: where does start-up time go

Provenance: Generated practice.

A node already holds the container image. The new replica must load 60 GB of weights at 4 GB/s and then spend 20 s on graph capture and warm-up. How long until it takes traffic, and which step would a pre-pulled image have removed?

Answer

Weight load: 60/4=1560 / 4 = 15 s. Add 20 s of warm-up: 35 s. The image pull is the step a pre-pulled image removes; on a node without the image it comes first and adds to the total.

Compare

Routing policies

PolicyWhat it doesWatch out for
Least loadedSends to the replica with the least work, measured by queue depth or cache useRequest counts hide a spread of 100 times in cost
Prefix-awareSends requests sharing a prefix to the replica holding its cached blocksHot spots; fall back to a lighter replica
Session affinityKeeps a chat on one replicaImbalance after long sessions
Adapter-awarePrefers replicas that already hold the adapterAdapter load time on a miss
Priority tiersSeparate pools or queues with reserved capacityIdle reserved capacity
Model routingEasy requests to a small modelThe router’s mistakes become quality errors; evaluate it

The vLLM prefix-caching page explains why prefix-aware routing pays: a block’s hash covers everything before it, so only a replica that saw the same leading tokens can reuse them.

Source4 Automatic Prefix Caching

Diagram

Prefix-aware routing

Diagram: The router sends requests that share a prefix to the replica that already holds its cache blocks, which skips most of the prefill.

if A is hot

Request, shared system prompt

Router hashes the prefix

Replica A: blocks cached

Replica B: cold

Lighter replica

Diagram summary: The router sends requests that share a prefix to the replica that already holds its cache blocks, which skips most of the prefill. If that replica is overloaded the router falls back to a lighter one, accepting a cache miss to avoid a hot spot.

Source4 Automatic Prefix Caching

Concept

Retries and hedging

  • The AWS Builders’ Library article calls retries selfish: they spend more of the server’s time to raise a client’s odds, and during overload they can delay recovery. It says APIs with side effects are not safe to retry unless they provide idempotency, and recommends jitter so retries do not collide.
  • For a streaming LLM call, retry only before the first token has reached the user, for idempotent calls, with the caller’s deadline passed along.
  • Hedging sends a second copy of a slow request to another replica. Dean and Barroso’s article discusses tail-tolerant techniques for services where rare slow responses dominate. Each LLM copy is GPU work, so hedging a share of requests adds that share to the load.

Sources5 Timeouts, retries, and backoff with jitter6 The Tail at Scale

Check yourself

Check: which failures are safe to retry

Provenance: Generated practice.

Four failures: (a) a classification call times out before any output; (b) a chat stream resets after 300 tokens reached the user; (c) a replica returns an overload error and says to retry later; (d) a tool-calling request fails with a server error after it may have charged a card. Which are safe to retry, under what rule, and what protects (d)?

Answer

(a) Yes: idempotent and nothing was shown. (c) Yes, once, with jittered back-off and the remaining deadline, ideally to a different replica; immediate repeated retries add load to an overloaded service. (b) No automatic replay: the user already has text, so a replay duplicates or contradicts it; resume from what was sent or show an error. (d) Not safe on its own, since the side effect may have happened. An idempotency key on the charge makes a retry harmless; without one, do not retry.

Source5 Timeouts, retries, and backoff with jitter

Compare

Benchmark mistakes and better practice

This table is the course’s reasoning. The vLLM page itself calls an infinite request rate with --max-concurrency the most common configuration for production benchmarking, which suits a gateway that caps concurrency; the table’s warning is about reading capacity from a closed loop.

MistakeBetter practice
Fixed prompt and output lengthsSample lengths from production traces, tail included
N clients that wait for each reply (closed loop)Arrivals at a set rate (open loop), so queues and tails appear
Only averages or peak throughputTTFT, ITL and end-to-end latency at p50, p95, p99; goodput across several load levels
No warm-upDiscard warm-up, measure steady state, test cold start separately
A prefix cache warm by accidentControl hit rate and measure with and without
Engines compared at different precisionFix hardware, precision, length limits and sampling, and check output quality

Source7 Benchmark CLI

Worked example

Worked: why the closed loop hides saturation

A service can complete 6 requests per second. In a closed loop with 40 clients and no think time, each client sends the next request only after the last reply. The system settles where latency is about 40/6=6.740 / 6 = 6.7 s per request and throughput is 6 per second. The report looks stable.

An open-loop test offers 9 per second regardless of replies:

QuantityArithmeticResult
Queue growth9−69 - 63 requests per second
Backlog after 10 minutes3×6003 \times 6001,800 requests
Wait for the newest1,800/61{,}800 / 6300 s

Real users do not wait for the previous user’s reply, so the open-loop number describes them.

Concept

What vLLM’s benchmark tool does

Read on 24 October 2026 (page dated 22 October):

  • --request-rate defaults to infinity, which sends everything at once; with a finite rate, arrivals follow a Poisson process by default.
  • --max-concurrency caps outstanding requests.
  • Sample output includes P99 for TTFT, TPOT and ITL.
  • Datasets include ShareGPT, random and custom JSONL files.
  • Repeated runs against the same server can reuse prompts left in the prefix cache and inflate throughput. Vary the seed, restart the server, or use vllm bench sweep serve, which resets caches between runs.

The number to report is goodput at your target on your traffic, not peak tokens per second on a synthetic run.

Source7 Benchmark CLI

Check yourself

Check: size the backlog

Provenance: Generated practice.

A replica group can complete 12 requests per second at target. An open-loop test offers 15 per second for 5 minutes. How long is the queue at the end, and how long does the newest request wait?

Answer

Queue grows by 15−12=315 - 12 = 3 per second; over 300 s that is 900 requests. The newest waits 900/12=75900 / 12 = 75 s, far past any interactive target. Report which loop was used, and test several offered rates around capacity.

Check yourself

Check: what is missing from this result line

Provenance: Generated practice.

A report reads: “Engine A: 5,100 tokens/s.” Name two numbers or settings you would ask for before comparing it with another engine.

Answer

Any two of: TTFT and ITL percentiles (p95, p99) and goodput at the target, since a throughput average hides tails; the prompt and output length distribution; whether arrivals were open or closed loop; the precision and hardware; whether the prefix cache was warm.

Source7 Benchmark CLI

Diagram

Triage a latency regression

Diagram: First ask what changed, then split by which latency moved.

TTFT up

ITL up

both

Latency worse

What changed?

TTFT or ITL?

Queue, cache, prompts, routing

Batch, context, throttling, links

Saturation

Diagram summary: First ask what changed, then split by which latency moved. A higher TTFT points at queueing, cache or prompt changes, routing or cold replicas; a higher ITL points at batch or context growth, throttling or slow links; both together under load mean saturation.

Source8 Optimization and Tuning

Compare

Symptom to first checks

SymptomFirst checks
TTFT up, ITL flatQueue time; KV usage and preemption count; prompt length distribution; prefix hit rate; router imbalance; replicas still warming
ITL up, TTFT flatBatch size and context length; large prefills sharing steps; GPU clocks and throttling; link health
Both up under loadCapacity: add replicas, shed load, cap tokens, fix the scaling signal
Cost and TTFT up, hit rate downA recent prompt change that moved varying text to the front

The vLLM tuning page (read 24 October 2026) says that when the cache runs short, requests are paused and recomputed, and lists remedies such as more memory for the cache, a lower max_num_seqs or token budget, or more parallelism. Method: reproduce, compare with a baseline, bisect the change, profile, fix, then add a test or an alert.

Sources8 Optimization and Tuning4 Automatic Prefix Caching

Worked example

Worked: a name at the front of the prompt

A prompt has a 1,800-token fixed system prompt followed by 200 tokens of user text. Assume blocks of 16 tokens (illustrative); the vLLM page says only full blocks are cached, and each block’s hash includes its parent’s.

Prompt layoutCached tokensPrefill tokens per request
Fixed text first112 full blocks = 1,7921{,}7922,000−1,792=2082{,}000 - 1{,}792 = 208
User name prepended0 (every block’s hash changes)2,000

Prefill work rises by 2,000/2082{,}000 / 208, about 9.6 times, while decode is unchanged, which matches a rise in TTFT and cost with a flat ITL and a falling hit rate. The repair is to put the per-user text after the shared prefix.

Source4 Automatic Prefix Caching

Compare

Failure modes and first mitigations

FailureWhat you seeMitigation
Out of GPU memoryCrashes on long promptsCap lengths, leave headroom, admission control, cache quantization
Preemption stormBusy GPU, falling goodputCap concurrency, add replicas, shorten context
Hung GPU or kernelStuck requests, healthy HTTPHealth check that generates a token; cordon and replace
Tensor-parallel peer lostWhole group stallsWatchdog timeouts, restart the group
Dropped clientsZombie sequencesCancel on disconnect, per-request timeouts
Deploy herdCold caches, long queuesGradual rollout, warm pools, limited retries
Bad rolloutSilent quality or speed lossCanary against control with an evaluation gate and automatic rollback
One tenant hoggingOthers starveQuotas, fair scheduling, separate pools

Only the canary description is sourced: the SRE workbook describes canarying as a partial, time-limited rollout whose metrics are compared with the rest of the fleet, with rollback when the canary is worse. The table rows and mitigations are the course’s own judgement about common failures, so check them against your engine.

Sources9 Chapter 16: Canarying Releases8 Optimization and Tuning

Concept

Degrade on purpose

When capacity runs out, choose what to lose instead of losing everything:

  • Shed low-priority traffic first.
  • Lower the maximum output tokens.
  • Switch some traffic to a smaller model.
  • Serve cached answers where they are valid.
  • Return a clear 429 or 503 with a retry hint, never a silent hang.

This list is the course’s judgement, not a sourced procedure. For multi-tenant services also scope prefix caches per tenant with a cache salt (lesson 2), redact prompts in logs, and limit tokens and concurrency per key.

Check yourself

Check: tail latency and a full cache

Provenance: Generated practice.

At the evening peak, p99 TTFT climbs to 12 s while p50 is 0.9 s. KV-cache usage reads 97 percent, preemptions are rising, and the GPU shows 90 percent busy. Give the likely cause, one page-worthy alert, two dashboard checks, and a fix with its price.

Answer

Likely cause: the cache is full, so requests wait for space and some are evicted and recomputed, which burns GPU time without finishing answers. Page on TTFT p95 or p99 above target, since users feel that. Dashboard: preemption count over time and the prompt-length distribution, which may show a few very long requests holding blocks. Fixes: cap context or concurrency (costs some rejected or truncated requests), add replicas (costs GPUs), quantize the cache (needs a quality check, lesson 3). Also move the scaling signal to KV usage so the next peak adds replicas earlier.

Source8 Optimization and Tuning

Check yourself

Check: what to shed first

Provenance: Generated practice.

A replica group sustains 6,000 output tokens per second at target, and the team wants to run it no hotter than 80 percent. Interactive traffic arrives at 22 requests per second with 200 output tokens. Batch traffic is 12 requests per second at 300 output tokens. What is the load, which class is shed first, and what share of batch must go? Would capping batch output at 100 tokens avoid shedding?

Answer

Interactive: 22×200=4,40022 \times 200 = 4{,}400 tokens/s. Batch: 12×300=3,60012 \times 300 = 3{,}600. Total 8,000, well over the ceiling of 0.8×6,000=4,8000.8 \times 6{,}000 = 4{,}800. Batch is shed first because it tolerates delay and users are not waiting. Room for batch: 4,800−4,400=4004{,}800 - 4{,}400 = 400 tokens/s, which is 400/3,600400 / 3{,}600, about 11 percent, so roughly 89 percent of batch must wait or be refused (with a 429 and a retry hint). Capping batch output at 100 tokens gives 12×100=1,20012 \times 100 = 1{,}200, still over 400, so the cap alone is not enough; it would have to combine with deferring most batch work to off-peak. The interactive class alone uses 4,400 of 4,800, so it has little spare for a burst.

Summary

Recap

  • replicas=peak/per-replica goodput capacity/target utilization\text{replicas} = \text{peak} / \text{per-replica goodput capacity} / \text{target utilization}, plus spares; then check Little’s law against the KV pool, because either can bind.
  • Scale on queue depth, KV utilization or TTFT, not CPU or GPU utilization alone; scale up fast, down slowly with a drain, and plan around cold start.
  • Route by work, not request count; use prefix and adapter affinity with a fallback; retry only safe failures; hedge sparingly.
  • Benchmark open loop on production-shaped traffic with percentiles, warm-up and cache control; report goodput at the target.
  • Page on symptoms, dashboard causes, triage by TTFT versus ITL, and degrade deliberately with clear errors.

References

References & Sources (1 of 2)

  1. Chapter 6: Monitoring Distributed Systems (opens in a new tab)

    Rob Ewaschuk2017Book

    Used for Monitoring answers what is broken and why; spend more effort on symptoms than causes; the four golden signals of latency, traffic, errors and saturation; every page should require intelligence.

  2. Metrics design (vLLM documentation) (opens in a new tab)

    vLLM project2026Documentation

    Used for Metric names for latency, KV-cache usage, prefix-cache hits, running requests, token counts and request success by finish reason; the page says naming may be revisited and shows request_success both with and without a total suffix. Page dated 12 October 2026.

  3. Loading models with Run:ai Model Streamer (vLLM documentation) (opens in a new tab)

    vLLM project2026Documentation

    Used for Reading tensors concurrently while streaming them to GPU memory from a local path or object storage, and the distributed option for loading from object storage or fast network file shares. Page dated 15 October 2026.

  4. Automatic Prefix Caching (opens in a new tab)

    vLLM project2026Documentation

    Used for Only full blocks are cached, and a block's hash includes its parent hash, which is why a changed prefix breaks reuse for every later block.

  5. Timeouts, retries, and backoff with jitter (opens in a new tab)

    Amazon Web Services (Builders' Library, AWS Builder Center)2019Article

    Used for Retries as selfish behaviour that can delay recovery during overload, the idempotency caveat for APIs with side effects, and jitter. Published 5 December 2019.

References

References & Sources (2 of 2)

  1. The Tail at Scale (opens in a new tab)

    Jeffrey Dean, Luiz André Barroso2013Communications of the ACM 56, pp. 74-80Article

    Used for Latency tail-tolerant techniques for large services where rare slow responses dominate (abstract only; the hedged-request idea on the slide is the course's summary of a common technique, not read from the cited page).

  2. Benchmark CLI (opens in a new tab)

    vLLM2026Documentation

    Used for Request rate default of infinity, Poisson arrivals at a finite rate, the concurrency cap, P99 in sample output, supported datasets, the prefix-cache warning for repeated runs and the sweep command that resets caches. Page dated 22 October 2026.

  3. Optimization and Tuning (opens in a new tab)

    vLLM project2026Documentation

    Used for Preemption and recomputation when the KV cache runs short, and remedies including cache memory share, sequence and token limits and parallelism. Page read 24 October 2026.

  4. Chapter 16: Canarying Releases (opens in a new tab)

    Alec Warner, Štěpán Davidovič2018Book

    Used for Canarying defined as a partial, time-limited deployment of a change and its evaluation against the rest of the fleet, with the release halted or reverted when the canary looks unhealthy.