KatInterview

Sizing a Fleet to Serve a Large Model to 100M Daily Users

System DesignModel answer
MediumModel answerSystem Designml-inferencecapacity-planninggpu-serving

Last updated

Plan an inference platform for 100M daily users: estimate traffic, memory, compute and bandwidth, pick hardware, control tail latency, and handle GPU out-of-memory failures.

You are asked to design the serving layer for a machine learning model used by 100 million daily active users. Interactive requests must be answered within a tight latency budget.

In your answer, cover the following:

  1. Requirements and assumptions. State which model you are sizing (type, parameter count, request shape) and the SLOs you target.
  2. Traffic estimate. Work from daily users to average and peak QPS, and to tokens or items per second.
  3. Memory budget. Account for weights, activations, caches, and the memory that batching consumes on each accelerator.
  4. Compute and bandwidth. Estimate FLOPs, memory bandwidth, and network needs, and turn them into a rough accelerator count.
  5. Hardware choice. Explain when you would use CPUs, GPUs, or specialized accelerators.
  6. Latency. Explain how you would reduce median and tail latency, including the batching and caching trade-offs.
  7. Reliability. Explain how you would prevent out-of-memory failures and recover when they happen.

Because "a model" is underspecified, begin by stating assumptions explicitly. Show your arithmetic and say how confident you are in each number.

Hints

Hint 1

Pin down the model first. A small ranking model and a multi-billion-parameter generative transformer lead to very different fleets, so fix one concrete example (parameters, layers, hidden size, tokens in and out) before doing any math.

Hint 2

Do two separate estimates for the accelerator count: one limited by compute (FLOPs per token times tokens per second) and one limited by memory bandwidth during token-by-token decoding. Then check what actually caps the batch size per GPU; it is often the per-sequence cache, not compute.

Hint 3

For tail latency and OOM, think about admission control and scheduling: cap context and output length, reserve memory by blocks, route by free cache capacity rather than round-robin, and decide in advance what gets preempted or shed when memory runs out.