Skip to content

2.1.3 The System Design Round

The system design round is the centerpiece of the Anthropic infrastructure loop, because it maps most directly onto what the infrastructure team does every day. You get 60 minutes on a virtual whiteboard or shared document, and the subject is almost always some combination of LLM inference infrastructure, distributed systems, and real-time streaming. The interviewer is not looking for a memorized diagram. They want to watch you clarify a problem, sketch a whole system, quantify its constraints, and reason about tradeoffs when they push on one corner of it.

Concepts from other sections (19)

This section uses these ideas. Each has a short definition and a link to the section that explains it in full. Tap a dotted term in the text to preview it.

  • Server-Sent Events (SSE): a unidirectional HTTP streaming protocol of text events separated by blank lines. Read more: 2.1.8 Streaming and Server-Sent Events
  • Constitutional AI: Anthropic’s method of aligning a model by having it critique and revise its outputs against a written set of principles. Read more: 2.1.5 The Hiring Manager Interview
  • SSE event: one data: ... block terminated by a blank line (\n\n) in a text/event-stream response. Read more: 25.3 The SSE streaming proxy in AI Engineering
  • Service Level Objective (SLO): a target for a defined measure of service behavior over a specified window. Read more: Chapter 13: Engineering Acronyms in Software Engineering
  • Load balancer: a component that spreads traffic across instances of a service by round-robin, least connections, or consistent hashing, at layer 4 (TCP) or layer 7 (HTTP). Read more: Chapter 1: System Design in Systems Engineering
  • Backpressure: limiting how far a producer can run ahead of a slow consumer, here by bounding the per-stream buffer. Read more: 2.1.8 Streaming and Server-Sent Events
  • Scatter-gather: the read path in which a coordinator fans a query out to every shard and merges their top-k results. Read more: Chapter 8: Search and Indexing in Systems Engineering
  • k-way merge: merging kk sorted lists by keeping their current heads in a min-heap of size kk and repeatedly taking the smallest, in O(Nlog⁡k)O(N \log k) time for NN elements in total. Read more: Chapter 6: Linked lists in Programming and Algorithms
  • TF-IDF: a lexical weighting that scores a term by its frequency in a document times its rarity across the corpus, so distinctive words count more than common ones; BM25 refines it. Read more: Chapter 27: Retrieval and RAG in AI Engineering
  • Inverted index: a map from each term to the sorted list of documents that contain it. Read more: Chapter 8: Search and Indexing in Systems Engineering
  • data parallelism (DDP): each rank holds a full model replica, computes the gradient of its batch slice, and all ranks average gradients before stepping. Read more: 17.3 Data parallelism and ZeRO stages 1 to 3 in AI Engineering
  • tensor / pipeline / expert parallelism: splitting a model across GPUs by weight matrix, by layer, or by MoE expert. Read more: Chapter 20: Inference Engines and GPU Deployment in AI Engineering
  • Mixture of experts (MoE): a layer of many expert MLPs of which a router picks kk per token. Read more: 13.8 Mixture of Experts in AI Engineering
  • AllReduce: a collective that combines a value across all GPUs and leaves the result on every GPU. Read more: 1.3 ML infrastructure patterns
  • Pipeline bubble: time a stage cannot perform useful work because the schedule has not filled or drained. Read more: 17.4 Parallelism, topology, and the global training batch in AI Engineering
  • Quantization: reducing numerical precision (for example, FP32 to INT8) to shrink and speed up a model. Read more: 2.6 Apple
  • fp16: a 16-bit format with 5 exponent bits and 10 mantissa bits; finer precision but a maximum of 65504 and a smallest subnormal of 2−242^{-24}. Read more: 17.1 Mixed precision, loss scaling, gradient accumulation, and activation checkpointing in AI Engineering
  • BF16: a 16-bit float with float32’s sign and exponent and 7 mantissa bits; the top half of a rounded float32. Read more: 6.7 Safetensors for every dtype, atomic checkpoints, and the token stream in AI Engineering
  • Cold start: the 40-to-90-second delay to load weights and warm kernels on a fresh GPU. Read more: 2.1.7 GPU Inference Serving

This section first lays out a time budget for the hour, then works through the most likely prompt, the infrastructure behind an LLM inference API, in depth: request flow, GPU memory, batching, the KV cache, autoscaling, streaming, and safety. It then covers two other reported prompts, a distributed search system and training infrastructure, and ends with the numeric targets you should be able to quote.

Learning objectives

  • Run a 60-minute design conversation with a deliberate time budget, from requirements to operations.
  • Design an LLM inference API end to end, from the HTTP request to streamed tokens.
  • Size GPU memory for weights and KV cache, and explain static versus continuous batching and PagedAttention.
  • Choose an autoscaling signal for GPU serving and justify warm pools.
  • Place safety filtering in a streaming pipeline without destroying latency.
  • Sketch a sharded search system and a training system, naming the key tradeoffs in each.

A design round goes wrong most often through pacing, so plan the hour before you start. Spend about five minutes clarifying requirements: scale, latency targets, and consistency needs. Spend about ten on the high-level architecture: components, data flow, and APIs. The bulk, about thirty minutes, is the deep dive, where the interviewer will steer you toward one or two areas. Reserve about ten minutes for operational concerns (monitoring, failure modes, scaling) and the last five for your questions.

The most likely prompt is to design the infrastructure behind Anthropic’s Claude API, from HTTP request to token output. Typical requirements are a time-to-first-token (TTFT) under 200 ms, 99.9% availability, support for both streaming (SSE) and non-streaming responses, graceful degradation under bursty traffic, and safety filtering that does not destroy latency.

Start with the whole picture before diving into any one box.

Client Request
|
v
[Load Balancer] --> [API Gateway]
| |
| [Auth / Rate Limit]
| |
v v
[Request Router] --> [Priority Queue]
| |
v v
[GPU Cluster] [Batch Scheduler]
| |
v v
[Model Worker] [KV Cache Manager]
|
v
[Safety Filter] --> [SSE Streaming Layer] --> Client

Walk the interviewer through it in request order. The API gateway handles authentication, rate limiting, and request validation. The request router sends each request to the right model version and GPU pool based on its properties: the model, max_tokens, and priority. Requests then wait in a priority queue, where paid tiers get higher priority and the queue depth doubles as an autoscaling signal. The batch scheduler groups queued requests into batches for efficient GPU utilization. The model worker runs inference on the GPU and produces tokens. The safety filter applies Constitutional AI checks to the generated content, and it can run in parallel with generation. Finally the streaming layer converts token output into SSE events and manages the connection’s lifecycle.

The deep dive usually starts with the GPU, because GPU memory is the scarcest resource in the system. It must hold four things with different lifecycles:

ComponentMemoryLifecycle
Model weightsFixed (~70GB for large model)Permanent while serving
KV cachePer-request, grows with sequence lengthDuration of request
Activation memoryPer-batch, transientPer forward pass
CUDA overheadFixedAlways

The practical consequence is admission control by memory planning. Before admitting a request, estimate its peak KV cache size from max_tokens, and reject or queue the request if there is not enough memory. Capacity follows from simple arithmetic:

Available GPU memory = Total - Weights - CUDA overhead
Max concurrent requests = Available / (avg KV cache per request)

Memory bounds how many requests fit; batching decides how well you use the GPU while they are there.

Static batching waits for N requests or T milliseconds, whichever comes first, and runs them together. It is simple, but it wastes capacity: short sequences that finish early leave their slots idle until the longest request in the batch completes.

Continuous batching is the preferred approach. As soon as a request completes, a new one is slotted into its place at the next iteration, which maximizes GPU utilization. Requests are also grouped by similar sequence length to minimize padding waste.

Iteration 1: [Req A (token 5), Req B (token 3), Req C (token 1)]
Iteration 2: [Req A (token 6), Req B (token 4), Req D (token 1)] # C finished, D slotted in

Within either scheme there is a flush-versus-hold tradeoff. Flushing sends a batch as soon as any request is ready, which lowers latency for that request. Holding waits until the batch is full, which raises throughput at the cost of latency. Production systems use a hybrid: flush after a short timeout, around 5 ms.

The key-value cache stores the attention keys and values for previously processed tokens, so each new token does not recompute them. Because it grows with sequence length and lives for the duration of a request, managing it is most of GPU memory management.

Three eviction policies are worth discussing. LRU evicts the least recently used cache entries when memory is full. Prefix-aware caching shares KV entries across requests with common prefixes, such as a shared system prompt. Preemption evicts the caches of lower-priority requests when high-priority requests arrive.

The technique to name is PagedAttention, from vLLM. It allocates the KV cache in fixed-size blocks (pages) rather than one contiguous region per request. That eliminates fragmentation and allows near-100% memory utilization, and pages can be shared across requests with common prefixes.

When the interviewer asks how the system scales, the key insight is the choice of signal. Queue depth weighted by estimated token count is a better scaling signal than raw GPU utilization. GPU utilization can read 90% with 2 requests or with 2000; queue depth captures actual demand.

scaling_metric = sum(estimated_tokens(req) for req in queue) / total_gpu_capacity
scale_up_threshold = 0.7
scale_down_threshold = 0.2

The other half of scaling is cold starts. Loading a large model onto a GPU takes 30 to 60 seconds, far longer than any latency SLO can absorb. So you maintain a warm pool of pre-loaded GPU instances, which is expensive but critical for the SLO, and size it from time-of-day traffic patterns. Cold-start instances handle overflow and workloads that are not latency-sensitive.

Anthropic streams responses as typed Server-Sent Events. A response is a sequence of events that open the message, open a content block, deliver deltas, and close both:

event: message_start
data: {"type": "message_start", "message": {"id": "msg_123", "model": "claude-sonnet-4-20250514", ...}}
event: content_block_start
data: {"type": "content_block_start", "index": 0, "content_block": {"type": "text", "text": ""}}
event: content_block_delta
data: {"type": "content_block_delta", "index": 0, "delta": {"type": "text_delta", "text": "Hello"}}
event: content_block_delta
data: {"type": "content_block_delta", "index": 0, "delta": {"type": "text_delta", "text": " world"}}
event: content_block_stop
data: {"type": "content_block_stop", "index": 0}
event: message_stop
data: {"type": "message_stop"}

Connection management is where the operational questions land. Send keep-alive heartbeat events so proxies and load balancers do not time out an idle stream. Support client-side reconnection with Last-Event-ID for resumability. And apply backpressure: if a client is slow to consume, buffer up to a limit and then drop the connection rather than letting buffers grow without bound. Streaming and SSE covers all of this in depth.

Safety is not optional in this round; always address where it fits. Constitutional AI constraints must be enforced without destroying latency, and a layered design does that. A pre-generation filter checks the input for known harmful patterns; it is fast and rule-based. A parallel safety classifier runs a lightweight safety model alongside generation and stops generation if it flags content. A post-generation filter makes a final check on the complete response before delivery.

Streaming makes the last layer hard, because tokens are sent as they are generated, before the response is complete. The answer is speculative checking: look ahead by a few tokens before sending. That adds a small delay but prevents unsafe content from reaching the client.

A second reported prompt asks for a search system over one billion documents at one million queries per second. The shape is scatter-gather over shards:

[Query API] --> [Query Router]
|
+-----------+-----------+
| | |
[Shard 1] [Shard 2] [Shard N]
| | |
+-----------+-----------+
|
[Merge Layer]
|
[Result API]

The first decision is the sharding strategy. Hash-based sharding gives an even distribution but forces a scatter-gather across every shard for every query. Content-based sharding co-locates related documents so some queries hit fewer shards. A hybrid uses hashing for even distribution plus extra replicas for popular content.

Even distribution does not prevent hot shards, so monitor per-shard latency percentiles, replicate hot shards dynamically, and route each query to the least-loaded replica.

The cross-shard merge has each shard return its top-K results with scores and the merge layer perform a K-way merge. The subtle challenge is consistent scoring across shards: TF-IDF depends on corpus statistics, so shards need normalization or shared global statistics for their scores to be comparable.

For the index structure, use an inverted index for text search, with posting lists that carry skip pointers for fast intersection, and a tiered layout: a hot tier in memory, a warm tier on SSD, and a cold tier in object storage.

For observability, track per-shard latency (p50 and p99), index freshness (time since the last update per shard), query error rate by type, and cache hit rate.

The internals behind these choices, from postings and skip pointers to scatter-gather and its pagination cost, are covered in Search and Indexing in Systems Engineering.

The third reported prompt is infrastructure for training large language models. Begin with the parallelism strategies, because the choice among them drives everything else:

StrategyWhat’s DistributedWhen to Use
Data parallelismTraining dataModel fits on one GPU
Model/Tensor parallelismModel layersModel too large for one GPU
Pipeline parallelismModel stagesVery deep models
Expert parallelismMoE expertsMixture-of-experts models

In data parallelism, each GPU holds a full copy of the model and processes different data, and gradients are synchronized with AllReduce. Scaling is near-linear until communication becomes the bottleneck. In model parallelism, the model is split across GPUs (for example, layers 0 to 11 on GPU 0 and layers 12 to 23 on GPU 1). That requires a high-bandwidth interconnect such as NVLink or InfiniBand, and it introduces pipeline bubbles, periods when some GPUs sit idle while others compute.

At this scale, failures are routine, so fault tolerance is a first-class requirement. Checkpoint model state every N steps to distributed storage. Support elastic training, so workers can be added or removed without a restart. Use redundant gradient computation to tolerate spot-instance preemption. And use RDMA (remote direct memory access) to bypass the CPU for GPU-to-GPU communication, which is critical to gradient synchronization performance.

Finally, gradient compression reduces the cost of synchronizing full gradients across many GPUs. The techniques are quantization (FP32 to FP16 or BF16), top-K sparsification, and error feedback. The tradeoff is some loss of training quality in exchange for a significant communication speedup.

Quantify everything in this round, and have these targets ready:

MetricTargetWhy
Time-to-first-token (TTFT)< 200msUser perception of responsiveness
Token throughput> 50 tokens/secReadable streaming speed
Availability99.9%Enterprise SLO requirement
Safety filter latency< 50ms overheadCan’t double response time for safety
Cold start time< 60sGPU warm pool sizing
Batch utilization> 80%GPU cost efficiency

Draw the full picture first and resist diving into one component too early. Quantify everything: how much memory, how many GPUs, what the latency budget is. Know the Anthropic API: read its documentation and understand the SSE event types, rate limits, and error responses. Always address how safety filtering fits into your design. And favor tradeoffs over perfection: the interviewers want to see you reason about choices, not recite a perfect architecture.

The serving concepts here are developed further in GPU inference serving, and the streaming layer in Streaming and SSE. For a ground-up build of an inference server, see the serving chapter of AI Engineering, starting with Continuous batching scheduler with priority and preemption; for the infrastructure under it, see Systems Engineering, starting from its front matter.

  • Time-to-first-token (TTFT): the latency from receiving a request to emitting its first output token.
  • KV cache: per-request storage of attention keys and values for already-processed tokens, so they are not recomputed.
  • Continuous batching: replacing finished requests in a running batch at each iteration, rather than waiting for the whole batch to finish.
  • PagedAttention: allocating the KV cache in fixed-size pages to eliminate fragmentation and allow prefix sharing.
  • Warm pool: GPU instances with the model already loaded, kept ready to absorb load without a cold start.
  • Speculative checking: holding back a few tokens of a stream so a safety check can run before they are sent.
  • Budget the hour: requirements, architecture, a 30-minute deep dive, operations, questions.
  • An inference API is gateway, router, priority queue, batch scheduler, model worker, safety filter, and SSE layer, in that order.
  • GPU memory holds weights, KV cache, activations, and CUDA overhead; admit requests by estimating peak KV cache from max_tokens.
  • Continuous batching and PagedAttention keep GPUs full; scale on token-weighted queue depth, and use warm pools to hide 30-to-60-second cold starts.
  • Layer safety (pre-filter, parallel classifier, post-filter) and use speculative look-ahead when streaming.
  • Search is sharded scatter-gather with careful cross-shard scoring; training is a choice of parallelism plus checkpointing and fault tolerance.
  1. Why is token-weighted queue depth a better autoscaling signal than GPU utilization for an inference service?
    AnswerGPU utilization can read 90% whether the GPU is serving 2 requests or 2000, so it says little about unmet demand. Queue depth weighted by estimated tokens measures the work actually waiting, which is what you need to provision for.
  2. A GPU has 80 GB, the weights take 70 GB, CUDA overhead is 2 GB, and the average request’s KV cache peaks at 0.5 GB. How many requests can run concurrently?
    AnswerAvailable memory is $80 - 70 - 2 = 8$ GB, so about $8 / 0.5 = 16$ concurrent requests. That is why admission control by estimated KV size matters.
  3. Why does continuous batching beat static batching for LLM serving?
    AnswerGenerated sequences have very different lengths. In a static batch, slots of requests that finish early sit idle until the longest one completes. Continuous batching slots a new request into a freed slot at the next iteration, keeping the GPU busy.
  4. How can you apply a safety check to a response that is being streamed token by token?
    AnswerUse speculative checking: buffer a few tokens ahead and run the check before sending them, alongside a parallel safety classifier that can stop generation. This costs a small delay but keeps unsafe content from reaching the client.
  5. In a hash-sharded search system, why can scores from different shards be hard to compare?
    AnswerTF-IDF and BM25 depend on corpus statistics such as document frequency and average length. Each shard computes them over its own subset, so the same document could score differently on different shards. Global statistics or normalization make scores comparable before the merge.
  6. When would you choose pipeline parallelism over data parallelism, and what cost do you take on?
    AnswerWhen the model is too large or too deep to fit on one GPU, you split it into stages across GPUs. You pay in pipeline bubbles, where some GPUs wait while others compute, and you need a high-bandwidth interconnect.