KatInterview

Design a Low-Latency LLM Inference API Service

System DesignModel answer
EasyModel answerSystem Designsystem designLLM servinginference

Last updated

Design a production-ready HTTP service that serves a single large language model to thousands of concurrent users with low latency and high throughput.

Scenario

Your team has fine-tuned a 7-billion-parameter text generation model. Product wants to expose it as a REST API that external developers can call. Within six months you expect:

  • 1,000 requests per minute at peak
  • Average prompt length: ~300 tokens; average output length: ~200 tokens
  • P95 latency target: first token in ≤ 1 second, full response in ≤ 8 seconds
  • The model weights fit in a single high-memory GPU (e.g., an 80 GB A100)

You do not need to design the training pipeline, billing, or authentication in depth — focus on the serving path.

What is expected

Walk the interviewer through:

  1. Requirements clarification — what questions would you ask, and what assumptions do you settle on?
  2. High-level architecture — components from client to GPU
  3. API design — key endpoints and parameters
  4. Request lifecycle and batching strategy — how a request travels through the system
  5. Scaling approach — how you handle traffic growth
  6. Key trade-offs — at least two concrete ones with reasoning

Hints

Hint 1

Think about what happens when many requests arrive simultaneously — can you process them together somehow, and what are the limits of doing so?

Hint 2

A single GPU can serve requests, but what sits in front of it? Consider what components handle routing, queuing, and load distribution.

Hint 3

Streaming responses (token by token) and batch responses have very different latency profiles — when would you choose each, and how does that affect your API contract?