Skip to content
Forward Deployed

Forward Deployed
AI Platforms and Scale

LLM Inference Serving

By Sourav Banerjee · Last updated 13 Oct 2026 · Report an issue

Case studyAdvanced6 documents, 48 min in total
For
Engineers preparing for Forward Deployed, solutions or applied-AI engineering interviews
Assumes
Comfort with retrieval, agents and basic cloud architecture — the related reviews below cover each
Objectives
  • Explain the system end to end at interview depth, including its dangerous constraint
  • Answer follow-up questions on components, failure modes, evaluation and rollout
How to use it
Read the tabs in order. The Interview Guide stands alone; later tabs assume it. Mark each tab as read to track the case as one unit.
Reading order
  1. Interview Guide · 7 min
  2. Technical Deep Dive · 5 min
  3. Quick Review · 2 min
  4. Full Design 1 · 11 min
  5. Full Design 2 · 12 min
  6. Full Design 3 · 11 min
Sources
The references for every tab are in Full Design 3 → References.

Cites its sources in the Sources and Full Design tab

Interview Guide · 7 min — Start here. The answer you would talk through in the interview, readable on its own.

LLM Inference Serving: Main Interview Guide

Source: Sources and Full Design, especially §§1–11 for the anchor and §§12–15 for variants. Use the Deep Dive for scheduling, KV (key–value) and failover mechanics and the Cheat Sheet for rehearsal. The source states that its serving design and all capacity figures are constructed examples, not measurements of an actual engine.

Questions to ask the interviewer

Ask Design consequence
Input and output tokens at p50/p95? Prices prefill, decode and KV memory.
Interactive or offline, streamed or whole response? Sets TTFT/TPOT SLOs and batch policy.
One model or many, variable output lengths? Determines pool isolation and continuous batching.
Peak/burst shape, tenants and priorities? Sets admission, fairness and headroom.
What should a caller see after mid-stream failure? Chooses continuation versus explicit partial error.

Requirements: Functional + Non-Functional

The easiest way to frame requirements in an interview is:

Functional = what the system does. Non-functional = how well it does it and what constraints it must satisfy.

Functional requirements — what the system must do

  1. Validate and tokenize requests.
  2. Apply per-tenant token budgets.
  3. Route to a healthy GPU with free KV capacity.
  4. Continuously batch variable-length generation.
  5. Demultiplex by request ID; stream and cancel.
  6. Handle replica / zone failure; reject overload early.
  7. Canary/drain model versions and split queue vs service metrics.

Non-functional requirements — how well / under what constraints

Requirement Example target / constraint
Latency Proposed p95 TTFT ≤500 ms, TPOT ≤50 ms at 1,000 rps. Load-test for real.
Reliability 99.9% explicit completion or failure; no lost or misdelivered request.
Fairness Tenant fairness; bounded queue; goodput within SLO.
Headroom ≤70% measured replica capacity; queueing delay climbs steeply past roughly 70–80% (rule of thumb).
Sizing (illustrative) 1,000 in / 250 out tokens; replica 20K in tok/s prefill (assumed, H100-class), 2.5K out tok/s decode ⇒ 0.15 replica-s/request. 1,000 rps at 70% ≈ 214 replicas. ~7 s/request ⇒ ~7,000 in flight; 64 seq/replica ⇒ ~110 slot replicas — compute is tighter.

Interview shortcut

If asked “What are the requirements?”, say:

“Functionally, admit, place on a replica with KV room, batch, stream, cancel, fail loud. Non-functionally, TTFT and TPOT SLOs, no lost streams, and tenant fairness — the model only does prefill and decode.”

Architecture

The LLM performs prefill and token-by-token decode. Code owns request identity, quotas, admission, placement, scheduling policy, health, retry budget and response routing. Replica-local memory checks have final authority over whether a sequence fits.

Diagram: Client; Gateway: auth, validate, CPU tokenize, request ID; Admission: tenant token bucket + bounded queue; 429 / Retry-After or batch defer; Router: free KV + queue + prefix affinity; (Capacity registry + health probes); Replica scheduler: continuous batching; LLM GPU: chunked prefill + decode + paged KV; Demux by request ID + detokenize; Token stream to client; Cancel sequence + release KV; Model registry / rollout / autoscalerDiagram: Client; Gateway: auth, validate, CPU tokenize, request ID; Admission: tenant token bucket + bounded queue; 429 / Retry-After or batch defer; Router: free KV + queue + prefix affinity; (Capacity registry + health probes); Replica scheduler: continuous batching; LLM GPU: chunked prefill + decode + paged KV; Demux by request ID + detokenize; Token stream to client; Cancel sequence + release KV; Model registry / rollout / autoscaler

Step-by-step architecture

  • The gateway authenticates, assigns a request ID, validates limits and tokenizes on CPU so estimated token work is known before GPU use.
  • Admission charges tenant tokens, places accepted requests in a bounded priority queue and returns a clear retry/defer signal when the SLO cannot be met.
  • The router samples healthy replicas using free KV blocks, queue length and shared-prefix warmth; the replica performs the final capacity check to avoid stale-registry herding.
  • A replica scheduler continuously adds waiting sequences and removes finished ones at decode steps; chunked prefill protects ongoing token streams from a long incoming prompt.
  • The GPU model runs prefill and decode while paged KV blocks are allocated on demand. Tokens are matched to callers by request ID, detokenized and streamed.
  • Health probes evict sick replicas. Unstreamed requests may retry under a budget; after partial output, the product either resumes by re-prefilling with caveats or returns an explicit partial error.
  • A client disconnect or stop request cancels model/tool work and frees KV. Rollouts drain replicas and canary new versions rather than dropping active requests.

Choices and failure modes

Continuous versus static batching: static generative batches wait for the longest output; short requests waste slots. Iteration-level batching lets each sequence leave as soon as it finishes. A size-or-time flush suits one-GPU fixed-shape synchronous work; variable-length generation still benefits from continuous batching.

KV memory is capacity: the source's illustrative 32-layer, eight-KV-head, 128-dimension fp16 model uses about 128KiB of KV per token. A 1,250-token sequence uses ~160MB; an 8,000-token sequence uses ~1GB. Paged allocation reduces reservation waste and fragmentation. The router must use free KV, not round-robin or only running-request count. Prefix affinity saves prefill only while the preferred replica has headroom.

Failover: liveness alone misses a hung GPU. Add readiness and a one-token deep probe. A failed replica loses its KV. Before any token streamed, retry elsewhere. After streaming, rebuilding state from prompt plus emitted text very likely matches under greedy decoding, but batch size and GPU kernels can still shift the floating-point results; sampling can diverge, so an explicit partial error may be the honest product choice. Cap retries and retain spare zone capacity to avoid a retry storm while replacement GPUs warm.

Cost: measure goodput per GPU-hour, batch occupancy, KV use, queue wait and cost per million output tokens. Cap output and cancel abandoned streams before buying more GPUs. Move non-interactive work to a batch tier and use prefix caching only on identical prefixes.

Variants and evaluation

For #75, a single GPU batcher flushes at 100 requests or a short wait; each synchronous caller has a request-ID future and timeout, and the queue is bounded. For #77, price the workload before saying 100K rps: the source's assumed chat shape implies ~21,400 replicas at 70%, while short completions imply ~2,570. Use independent cells and global backpressure so one hot tenant or deploy does not damage the fleet. For #79, lead a review with the three highest risks and their fixes.

Track p50/p95 TTFT, TPOT, queue wait, service time, prefill/decode throughput, prefix hit rate, KV occupancy/preemptions, cancellation delay, explicit failures and goodput (requests finished within SLO). Load-test actual prompt/output distributions, zone failure, stale capacity heartbeats, long-prefill interference and overload before claiming the illustrative replica count works.

Two-minute interview answer

“I would ask for input and output token distributions and the first-token and per-token targets before sizing. I tokenize at the gateway, admit by per-tenant token budget and bounded queue, then route by free KV capacity rather than round-robin. Each GPU schedules continuously, admitting and finishing sequences at decode steps, with chunked prefill and paged KV to protect latency and memory. Tokens are demultiplexed by request ID and streamed; disconnect cancels the sequence. A capacity registry plus readiness and one-token probes evicts sick GPUs. Unstreamed work retries under a budget; streamed work has an explicit continuation or partial-error policy. The source’s 214-replica example is arithmetic on assumed throughput, so I would validate it with goodput, TTFT, TPOT and KV use on the actual model.”

Where next

Revise the concepts