Design ChatGPT's Inference Service

Harder 6
StreamingLLM Serving OpenAI

Design the serving system for a chat product built on an open-weights model that you host yourself on your own GPUs. Users type a message and watch the reply stream in, token by token.

Functional:

  • Accept a conversation (the previous messages plus a new one) and stream the reply back token by token.
  • Support two model sizes, a fast small model for free users and a large model for paid users.
  • Let a user stop a reply mid-stream.
  • Enforce per-user rate limits that differ by plan.

Non-functional:

  • Time to first token under 800 ms at p95 for the small model.
  • At least 30 tokens per second per stream once a reply starts.
  • Keep expensive GPUs busy: aim for high batch occupancy without breaking the latency targets.
  • One GPU node failing must not drop more than the replies it was generating.
  • 1 million daily users, 40,000 concurrent streams at peak.
  • Conversations average 3,000 tokens of context, replies 400 tokens.
  • The large model needs 8 GPUs per replica; the small model fits on 1 GPU.
  • Long system prompts are shared by every conversation.

Training, safety classifiers, and the chat UI.

System design
Loading editor...