Slides · Inference engineering
Production operations: capacity, scaling and failure
1 / 32
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
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.
Compare
Page on symptoms, dashboard the causes
| Page on (symptoms) | Dashboard (causes) |
|---|---|
| TTFT and ITL percentiles against target | Running and waiting requests, queue time |
| Error rate | KV-cache utilization, prefix-cache hit rate |
| Goodput | Preemptions, 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.
Sources[2] Metrics design (vLLM documentation)[1] Chapter 6: Monitoring Distributed Systems
Process
The capacity method
- 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.
- Benchmark one replica on that distribution at the latency target. Its capacity is the goodput it sustains, not its peak tokens per second.
- replicas=per-replica capacity×target utilizationpeak load, 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.
- 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.
| Step | Arithmetic | Result |
|---|---|---|
| Peak output rate | 30×250 | 7,500 tokens/s |
| Raw replicas | 7,500/2,000 | 3.75 |
| With margin | 3.75/0.65 | 5.8, so 6 |
| Plus one spare | 6+1 | 7 replicas, 28 GPUs |
| Time in system | 0.5 s+249×0.03 s | about 8 s |
| In flight (Little’s law) | 30×8 | about 240 |
| Per serving replica | 240/6 | 40 |
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_systemper_replica=serving_replicasin_flightfits⟺per_replica≤sequences_the_pool_holds| Symbol | Meaning |
|---|---|
| arrival_rate | Requests per second at the peak being planned for |
| time_in_system | Seconds from admission to the last token, including queueing |
| 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,520 tokens/s. 2,520/1,500=1.68; /0.6=2.8, so 3 serving replicas, 4 with the spare. Time in system: 0.5+179×0.03=5.87 s, so 14×5.87=82 in flight, 27.4 per replica across 3. That exceeds 25, so the cache binds: 82/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
| Signal | Leads or lags | Why |
|---|---|---|
| Waiting requests or queue depth per replica | Leads | Requests queue before anyone sees slow answers |
| KV-cache utilization near its limit | Leads | A full pool means queueing and eviction are next |
| Running sequences against the benchmarked limit | Leads | Compares load with measured capacity |
| TTFT p95 approaching target | Leads, late | A direct symptom that moves as queues build |
| GPU utilization alone | Misleads | A busy GPU can be saturated or redoing evicted work, so it does not say whether another replica helps |
| CPU utilization | Misleads | GPU 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
Source[3] 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 rate | Arithmetic | Time |
|---|---|---|
| 2 GB/s | 140/2 | 70 s |
| 5 GB/s | 140/5 | 28 s |
| 10 GB/s | 140/10 | 14 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=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.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=540 s to clear), and 12 at the 0.65 target (60/8/0.65=11.5; capacity 96, surplus 36, backlog cleared in 2,160/36=60 s once all are ready). One extra replica is nowhere near enough.
Source[3] 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=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
| Policy | What it does | Watch out for |
|---|---|---|
| Least loaded | Sends to the replica with the least work, measured by queue depth or cache use | Request counts hide a spread of 100 times in cost |
| Prefix-aware | Sends requests sharing a prefix to the replica holding its cached blocks | Hot spots; fall back to a lighter replica |
| Session affinity | Keeps a chat on one replica | Imbalance after long sessions |
| Adapter-aware | Prefers replicas that already hold the adapter | Adapter load time on a miss |
| Priority tiers | Separate pools or queues with reserved capacity | Idle reserved capacity |
| Model routing | Easy requests to a small model | The 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.
Diagram
Prefix-aware routing
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.
Sources[5] Timeouts, retries, and backoff with jitter[6] 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.
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.
| Mistake | Better practice |
|---|---|
| Fixed prompt and output lengths | Sample 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 throughput | TTFT, ITL and end-to-end latency at p50, p95, p99; goodput across several load levels |
| No warm-up | Discard warm-up, measure steady state, test cold start separately |
| A prefix cache warm by accident | Control hit rate and measure with and without |
| Engines compared at different precision | Fix hardware, precision, length limits and sampling, and check output quality |
Source[7] 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.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:
| Quantity | Arithmetic | Result |
|---|---|---|
| Queue growth | 9−6 | 3 requests per second |
| Backlog after 10 minutes | 3×600 | 1,800 requests |
| Wait for the newest | 1,800/6 | 300 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-ratedefaults to infinity, which sends everything at once; with a finite rate, arrivals follow a Poisson process by default.--max-concurrencycaps 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.
Source[7] 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=3 per second; over 300 s that is 900 requests. The newest waits 900/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.
Source[7] Benchmark CLI
Diagram
Triage a latency regression
Compare
Symptom to first checks
| Symptom | First checks |
|---|---|
| TTFT up, ITL flat | Queue time; KV usage and preemption count; prompt length distribution; prefix hit rate; router imbalance; replicas still warming |
| ITL up, TTFT flat | Batch size and context length; large prefills sharing steps; GPU clocks and throttling; link health |
| Both up under load | Capacity: add replicas, shed load, cap tokens, fix the scaling signal |
| Cost and TTFT up, hit rate down | A 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.
Sources[8] Optimization and Tuning[4] 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 layout | Cached tokens | Prefill tokens per request |
|---|---|---|
| Fixed text first | 112 full blocks = 1,792 | 2,000−1,792=208 |
| User name prepended | 0 (every block’s hash changes) | 2,000 |
Prefill work rises by 2,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.
Compare
Failure modes and first mitigations
| Failure | What you see | Mitigation |
|---|---|---|
| Out of GPU memory | Crashes on long prompts | Cap lengths, leave headroom, admission control, cache quantization |
| Preemption storm | Busy GPU, falling goodput | Cap concurrency, add replicas, shorten context |
| Hung GPU or kernel | Stuck requests, healthy HTTP | Health check that generates a token; cordon and replace |
| Tensor-parallel peer lost | Whole group stalls | Watchdog timeouts, restart the group |
| Dropped clients | Zombie sequences | Cancel on disconnect, per-request timeouts |
| Deploy herd | Cold caches, long queues | Gradual rollout, warm pools, limited retries |
| Bad rollout | Silent quality or speed loss | Canary against control with an evaluation gate and automatic rollback |
| One tenant hogging | Others starve | Quotas, 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.
Sources[9] Chapter 16: Canarying Releases[8] 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.
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,400 tokens/s. Batch: 12×300=3,600. Total 8,000, well over the ceiling of 0.8×6,000=4,800. Batch is shed first because it tolerates delay and users are not waiting. Room for batch: 4,800−4,400=400 tokens/s, which is 400/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,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, 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)
Chapter 6: Monitoring Distributed Systems (opens in a new tab)
Rob Ewaschuk2017Book
https://sre.google/sre-book/monitoring-distributed-systems/
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.
Metrics design (vLLM documentation) (opens in a new tab)
vLLM project2026Documentation
https://docs.vllm.ai/en/latest/design/metrics.html
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.
Loading models with Run:ai Model Streamer (vLLM documentation) (opens in a new tab)
vLLM project2026Documentation
https://docs.vllm.ai/en/latest/models/extensions/runai_model_streamer.html
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.
Automatic Prefix Caching (opens in a new tab)
vLLM project2026Documentation
https://docs.vllm.ai/en/stable/design/prefix_caching/
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.
Timeouts, retries, and backoff with jitter (opens in a new tab)
Amazon Web Services (Builders' Library, AWS Builder Center)2019Article
https://builder.aws.com/content/3EumjoZascWd1oZiEgL8ORlv3qE/timeouts-retries-and-backoff-with-jitter
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)
The Tail at Scale (opens in a new tab)
Jeffrey Dean, Luiz André Barroso2013Communications of the ACM 56, pp. 74-80Article
https://research.google/pubs/the-tail-at-scale/
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).
Benchmark CLI (opens in a new tab)
vLLM2026Documentation
https://docs.vllm.ai/en/latest/benchmarking/cli/
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.
Optimization and Tuning (opens in a new tab)
vLLM project2026Documentation
https://docs.vllm.ai/en/latest/configuration/optimization.html
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.
Chapter 16: Canarying Releases (opens in a new tab)
Alec Warner, Štěpán Davidovič2018Book
https://sre.google/workbook/canarying-releases/
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.
Keys: ← → move, Home End first and last, F full screen.