Part 6 · Blueprint 32
High-Throughput LLM Inference Serving
15 min reading · Sources · Editorial review pending
Request counts hide the memory and time demanded by different token lengths.
Page details
Published date · Last edited:
Draft edition. Editorial review and supplementary reading recommendations are still being completed.
Format: Architecture walkthrough. Prerequisites: the beginner bootcamp. Chapter prerequisites: Back-of-Envelope Capacity Estimation, Rate Limiting Algorithms: Token Bucket to Sliding Window, Timeouts, Circuit Breakers & Backpressure.
Sixty-second mental model
Problem: Request counts hide the memory and time demanded by different token lengths.
Use: Budget weights and active sequence state before batching.
Design boundary: Serve model requests within latency and memory budgets. Distinguish queued requests, prefill work, decoding steps and retained attention state. Batch size alone does not describe capacity.
Layer 1 · Intuition
Hypothetical scenario: Northwind is designing model inference serving. Maya represents product requirements, Dev implementation and Priya reliability. The team must agree what one token means and which component owns the serving admission policy.
Think of a kitchen batching dishes while managing scarce workspace. Separate the requester from serving admission policy, then identify the retained evidence needed after failure.
- Authority
- The entitled state owner.
- Invariant
- A rule preserved across concurrency and failures.
- Continuous batching
- Scheduling that changes active inference requests across generation iterations. Analogy: Filling a freed service slot without waiting for the whole group to finish.
- Decode
- The autoregressive phase generating additional output tokens using prior context. Analogy: Writing the next answer tile from the context so far.
- KV cache
- Stored attention keys and values reused during autoregressive inference. Analogy: Keeping intermediate notes instead of rereading every calculation.
- Prefill
- The inference phase processing prompt tokens to establish model state before subsequent generation. Analogy: Reading the question before composing an answer.
- Token
- A model-specific unit of encoded input or output, which need not equal a word. Analogy: One tile in a model's own text alphabet.
Architecture and worked reasoning
Design boundary: Serve model requests within latency and memory budgets. Distinguish queued requests, prefill work, decoding steps and retained attention state. Batch size alone does not describe capacity.
Responsibilities on the request path
Workload and limiting resource
Hypothetical state model: 32 layers × 2 key/value tensors × 8 heads × 128 dimensions × 2 bytes = 131,072 bytes/token. At 4,096 tokens this is 536,870,912 bytes/request before allocator overhead; 16 such requests consume 8 GiB of raw KV state. These are chosen model dimensions, not a vendor benchmark.
Keep the units attached to each intermediate result. The assumptions above describe a hypothetical exercise, not observed vendor capacity. A real capacity decision also needs a measured service curve, skew, recovery traffic and an explicit admission policy for overload.
Mutation or publication path
- Validate input/output bounds and admit within memory budget.
- Schedule prefill without starving active decodes.
- Reserve and release per-request state through completion or cancellation.
Observation and recovery path
- Stream output with explicit completion state.
- Track first-token and inter-token latency separately.
- Reject or defer requests that cannot fit the declared resource budget.
Failure that changes the decision
Hypothetical scenario: Long prefills monopolize compute while active streams stall. Budget prefill/decode separately and bound sequence lengths and queue residence.
Attempt this decision before reading the explanation
Can more concurrent requests always improve serving throughput?
No. Memory pressure, padding, scheduling and decode interference can reduce useful completion rate or violate latency. Measure accepted-task throughput within the promised latency/resource envelope.
Supporting mechanism analysis
Hypothetical scenario: Northwind. Maya represents product, Dev implementation and Priya reliability. The following workflow develops the underlying mechanism.
Hypothetical scenario. Northwind’s request measurements show short and long conversations sharing serving capacity. A sequence finishes while another continues. Maya asks why queued work still waits; Dev considers iteration-level scheduling, and Priya asks what memory the new request will need as it grows.
Maya: “A finished sequence should not make another request wait for the longest answer.”
Priya: “Reuse the opening only when the growing state remains within the admission budget.”
You will separate continuous batching from PagedAttention, then connect their scheduling and KV-management roles to vLLM and TensorRT-LLM. Derive reusable slots in the teaching example without treating them as measured GPU capacity.
Before you continue: A sequence finishes and frees a scheduling slot. Is that alone enough to admit any waiting request?
A slot count does not establish available memory for prefill and growing KV state. A longer request can violate the resource budget even when the scheduler has an opening.
This separates useful scheduling flexibility from safe admission. Account for request shape, memory growth and the actual runtime rather than converting slot arithmetic into a throughput guarantee.
Continuous batching allows scheduling decisions across generation iterations rather than holding an entire request batch until its longest sequence finishes. PagedAttention manages logical KV state using blocks rather than requiring one expanding contiguous reservation. These are complementary scheduling and memory-management decisions. The vLLM paged-attention design explains block-based access. TensorRT-LLM's architecture documentation gives another concrete serving stack; compare supported scheduling, kernels, quantization and adapter behavior for the actual deployment.
Hypothetical scenario. Three active sequences need four, two and one further decode iterations. Under a simple one-slot-per-sequence model, reserving all three slots for four iterations allocates 3 × 4 = 12 slot-iterations. Their useful demand is 4 + 2 + 1 = 7, leaving five potentially reusable slot-iterations. Admitting replacement work can use those openings, but actual kernel efficiency and memory limits are not established by this count. Admission must account for the memory that new requests will grow into, not just their first iteration.
Northwind receives a short policy lookup and a document-heavy investigation at the same moment. Dev's router sends both to a preferred model because its historical average quality looks good. Sam sees the long request hold cache while short requests wait, and Priya notices that the cheaper fallback cannot satisfy the investigation's evidence contract.
The routing decision needs more than a model name. Identify allowed data destinations, required capabilities, context limits and task acceptance. Then consider current capacity and the request's deadline. A model can be eligible yet temporarily unavailable; an idle model can be ineligible. Keeping those distinctions explicit makes rejection and degradation understandable.
Hypothetical scenario. Continuous batching can admit new work as sequences finish instead of waiting for an entire fixed batch. The scheduler still must account for token shapes, memory and shared prefill/decode work. A freed request slot does not necessarily equal enough KV capacity for any waiting request.
Paged KV management changes allocation and reuse behavior; it is not unlimited memory. Record the selected engine, layout, block policy and cancellation lifetime. Compare vLLM and TensorRT-LLM under a common task, hardware and workload contract rather than transferring one engine's configuration semantics to the other. Track queue age and useful completion by request class so long prefills cannot silently consume all short-request capacity.
Eligibility includes the caller's permissions, input modalities, tool contract, evidence requirements and allowed processing locations. Enforce these rules outside a generated classification. A model that predicts “simple request” cannot authorize sending protected text to a destination that the application disallows.
Within the eligible set, routing can use measured task behavior, selected cost assumptions and workload constraints. An intent classifier is one possible hint. Its errors belong in evaluation: an apparently easy request can contain a rare condition that requires a different model or a human decision. Preserve a route reason and fallback policy with the request.
A request rate counts arrivals over time. A token allowance accounts for a selected amount of input and possible output work. Concurrency counts work still outstanding and can reflect held cache or remote resources. All three can matter, and limiting one does not impose a reliable bound on the others.
Two requests can differ greatly in input size, output bound and service time. A requests-per-second policy that treats them equally may admit a harmful burst of large requests. Conversely, a token allowance alone can permit too many small slow tasks that wait on tools. Add limits for the actual held resources rather than assuming one currency captures every bottleneck.
Token counts also depend on the destination's tokenizer and representation. Do not transfer a reservation between providers as if one reported token meant identical work everywhere. Define the budget unit and recompute it when the request format or selected destination changes.
Hypothetical scenario. Choose a bucket capacity of 10,000 work tokens with 8,000 currently available. A request has a selected 4,000-token input and a maximum 3,000-token output. Reserving the full selected bound requires 4,000 + 3,000 = 7,000 tokens, leaving 8,000 − 7,000 = 1,000 available.
A second request needs a reservation of 3,000. It cannot fit immediately. If the chosen refill rate is 2,000 tokens per second and no other work consumes tokens, one second adds 2,000 and makes 3,000 available. That is a toy budget calculation, not a promise about accelerator throughput or a provider's billing policy.
If the first request actually uses 4,000 input and 1,000 output tokens, its selected actual total is 5,000. The unused 2,000 reservation can be reconciled according to the budget policy. Guard against double reconciliation when a response is retried or completed twice. An uncertain attempt may have consumed remote work even when the client has no final usage record.
Choose a fluid approximation with 120 requests per second arriving and 100 requests per second completing. Outstanding work grows at 120 − 100 = 20 requests per second while those rates persist. In ten seconds, the selected growth is 20 × 10 = 200 requests. Real requests vary, but this simple imbalance already rules out an indefinitely stable queue.
Layer 3 · Internals
Trade-offs and limits
| Approach | Provides | Requires |
|---|---|---|
| Static request batch | Simple grouping and scheduling for a bounded workload. | Unequal sequence lifetimes can leave resources underused. |
| Iteration-level batching | Can admit new work as active sequences progress. | KV memory, fairness and per-request latency still constrain admission. |
Recovery decision
Hypothetical scenario: Long prefills monopolize compute while active streams stall. Budget prefill/decode separately and bound sequence lengths and queue residence.
No. Memory pressure, padding, scheduling and decode interference can reduce useful completion rate or violate latency. Measure accepted-task throughput within the promised latency/resource envelope.
Write your design before revealing the review
Can more concurrent requests always improve serving throughput?
Drafts and self-review are stored only in this browser. They are separate from reading completion.
Compare your decision
No. Memory pressure, padding, scheduling and decode interference can reduce useful completion rate or violate latency. Measure accepted-task throughput within the promised latency/resource envelope.
Long prefills monopolize compute while active streams stall. Budget prefill/decode separately and bound sequence lengths and queue residence.
Check your understanding
Can more concurrent requests always improve serving throughput?
No. Memory pressure, padding, scheduling and decode interference can reduce useful completion rate or violate latency. Measure accepted-task throughput within the promised latency/resource envelope.
How would you recover from this failure: Long prefills monopolize compute while active streams stall. Budget prefill/decode separately and bound sequence lengths and queue residence.
Start with the exact boundary that failed. Validate input/output bounds and admit within memory budget. Schedule prefill without starving active decodes. Reserve and release per-request state through completion or cancellation. Then recover evidence through the observation path: Stream output with explicit completion state. Track first-token and inter-token latency separately. Reject or defer requests that cannot fit the declared resource budget. Preserve the distinction between a confirmed state change and an unavailable response.
Which assumption in the worked calculation would a burst or concentrated tenant invalidate first?
Hypothetical state model: 32 layers × 2 key/value tensors × 8 heads × 128 dimensions × 2 bytes = 131,072 bytes/token. At 4,096 tokens this is 536,870,912 bytes/request before allocator overhead; 16 such requests consume 8 GiB of raw KV state. These are chosen model dimensions, not a vendor benchmark. Recompute the affected resource rather than multiplying unrelated storage and network budgets by the same factor. Serve model requests within latency and memory budgets. Distinguish queued requests, prefill work, decoding steps and retained attention state. Batch size alone does not describe capacity.
Which component in this topology could be removed from a smaller first deployment?
Request admission, Prefill scheduler, Decode batch, Device memory name responsibilities, not a requirement for separate processes. Co-locate responsibilities when their transaction, trust and capacity boundaries permit it. Validate input/output bounds and admit within memory budget.
What evidence must a caller have before relying on the observation path?
Stream output with explicit completion state. Track first-token and inter-token latency separately. Reject or defer requests that cannot fit the declared resource budget. No. Memory pressure, padding, scheduling and decode interference can reduce useful completion rate or violate latency. Measure accepted-task throughput within the promised latency/resource envelope.
45-minute interview rubric
- 00–05: scope token and serving admission policy.
- 05–12: identify the limiting resource and derive the domain workload above, retaining units and assumptions.
- 12–28: draw serving admission policy, numbered writes and reads.
- 28–40: challenge recovery: Budget weights and active sequence state before batching.
- 40–45: defend request_id placement, observations and remaining assumptions.
Go deeper
- Paged Attention - vLLM · Primary document · docs.vllm.ai. Budget weights and active sequence state before batching. Verified 2026-10-26.
- Optimization and Tuning - vLLM · Primary document · docs.vllm.ai. Budget weights and active sequence state before batching. Verified 2026-10-26.
- Overview — TensorRT LLM · Primary document · nvidia.github.io. Budget weights and active sequence state before batching. Verified 2026-10-26.
- Adaptive Concurrency — envoy 1.41.0-dev-a40510 documentation · Primary document · www.envoyproxy.io. Budget weights and active sequence state before batching. Verified 2026-10-26.
Decision log
Budget weights and active sequence state before batching.
Preserve token identity and serving admission policy ownership.
Revisit changed workload, observations or recovery objectives.