KatInterview

Serving a 70B LLM to Thousands of Concurrent Streaming Users

System DesignModel answer
HardModel answerSystem Designllm-servingcontinuous-batchingkv-cache

Last updated

Design a multi-GPU inference platform for a 70B model that streams tokens with low first-token latency, keeps GPUs busy, manages KV cache memory, and survives traffic spikes.

Build an inference platform for a large language model

You are asked to design the backend that serves a roughly 70-billion-parameter language model to thousands of users at the same time. Some users are in interactive chat sessions and expect tokens to appear as they are generated. Others submit large offline jobs and care only about total throughput.

What the platform must do

  • Stream generated tokens back to the client incrementally (server-sent events).
  • Expose an API for submitting generation requests with tunable settings such as maximum output length and sampling temperature.
  • Host several model versions at once, and let operators move traffic to a new version atomically.

Qualities to optimize

  • Keep time to first token (TTFT) as low as possible.
  • Keep expensive GPUs as busy as possible.
  • Absorb sudden load surges without falling over.

Given facts

  • Inference runs on a fleet of machines with large-memory GPUs.
  • The attention key/value cache (KV cache) is the main memory pressure point.
  • The weights do not fit on one GPU, so the model must be split across devices with tensor and/or pipeline parallelism.

What to cover in your answer

  1. Architecture: how a request is routed, queued, and executed.
  2. Scheduling and batching: how you would run continuous batching when requests have very different prompt and output lengths.
  3. Memory: how you would manage KV cache to avoid fragmentation and out-of-memory failures.
  4. Scaling: how the fleet should grow and shrink around peak hours and bursts.

State your assumptions about load and latency targets, and justify them with rough capacity math.

Hints

Hint 1

Start from hardware arithmetic: weight size in bytes, KV cache bytes per token (layers x KV heads x head dim x 2 x precision), and how many concurrent sequences fit in the memory left over after weights.

Hint 2

Static batches waste capacity because short requests wait for long ones. Think about rebuilding the batch at every decode step, and about how a long prompt (prefill) can stall everyone else's token generation.

Hint 3

Treat KV memory like OS virtual memory: fixed-size blocks, a per-request block table, and reference counting for shared prefixes. For spikes and updates, think about preemptible batch work, admission control, warm capacity, and pinning each request to one model version.