Design a Batched LLM Inference API

LLM ServingQueues Anthropic

Design the API layer in front of a pool of GPU workers that serve a language model. Each worker exposes one call, infer(batch), that returns a completion for every prompt in the batch in about 100 ms, whether the batch holds 1 prompt or 32. Callers send one prompt each and must get back only their own completion.

Functional:

  • Accept single completion requests over HTTP and return each caller its own result.
  • Group concurrent requests into batches of up to 32 per GPU worker.
  • Honor a per-request timeout and let callers cancel.
  • Record token usage per request.

Non-functional:

  • Added queueing delay under 50 ms at p50 under normal load. End to end under 2 seconds at p99.
  • Keep GPU utilization above 70% at peak, because the GPUs are the expensive part.
  • A failed batch or a crashed worker must not lose or silently duplicate anyone's request.
  • Under overload, reject early with a clear error instead of queueing forever.
  • 10,000 requests per second at peak. Prompts average 1,000 tokens.
  • 60 GPU workers. Each infer call takes about 100 ms for up to 32 prompts, so one worker tops out near 320 requests per second.
  • Callers keep their HTTP connection open until their completion comes back.

The model, KV cache internals, training, and billing.

System design
Loading editor...