Design an LLM Inference Platform
Serve several open language models to every product team through one API, with streaming, fair quotas and a cost per token you can predict.
Like a busy kitchen with a few very expensive ovens. Orders are grouped so no oven sits idle, and each team gets a fair share of oven time. A queue shows when to fire up another oven.
Where this analogy stops working: An oven cooks each dish in one go. A GPU writes every answer one token at a time. Its memory, not only its time, limits how many answers it can hold at once.
- Teams
- Product team apps
- Gateway
- Gateway
- Routing
- Router
- Queue per model
- GPUs
- Chat lane GPUs
- Batch lane GPUs
- 70B model
- Usage
- Usage metering
1. Requirements and scope
- One API for every team: send a prompt, choose a model, get the answer streamed back token by token.
- Serve several models, such as a small fast one and a large accurate one, and add new versions safely.
- Give each team a token quota and a rate limit, and report usage for billing.
- Offer a cheaper batch lane for work that can wait, such as summarising yesterday's tickets.
- Time to first token under about 0.5 s for 95 of every 100 chat requests (the p95).
- At least 20 tokens a second for each streaming answer, faster than people read.
- Keep GPUs busy, since they are the main cost.
- One team's traffic spike must not slow the other teams down.
2. Back-of-the-envelope numbers
3. API
4. Data model and storage
MODEL(id, version, weights_uri, gpus_needed, max_context) · TEAM(id, tokens_per_minute, daily_tokens) · USAGE(team_id, model, minute, tokens_in, tokens_out)
5. The design, in three versions
Version 1: One model on one GPU server
A single server loads one model and answers requests one batch at a time. A new batch starts only when the whole previous batch has finished.
Inference v1: One Model on One GPU Server Version 1 of 3
The picture follows one request through the parts of this version, in order. Under it, switch a part off to see what the request does without it.
One request, step by step
Each numbered arrow is one step. Press "Simulate Request Flow" to follow them one at a time.
- The order of the steps
- A request or its reply
The parts: switch one off
1. Teams
Example figures
- Speaks
- HTTPS + SSE
2. Gateway
Example figures
- Time budget
- < 5 ms
3. GPU
Example figures
- Capacity
- Idle slots
The steps in words0 of 3 steps shown
Team app to API server
POST /v1/completions { model, messages, stream: true }
API server to GPU
Waits for the whole previous batch to finish
GPU to Team app
Tokens stream back, about 20 a second or faster
Write path, read path and failures
Each path follows one request through the final design (version 3), one hop at a time.
Write pathRoll out a new model version
- Model team
- Weight store
- Chat lane GPUs
- Router
Model team to Weight store
The team uploads the new weights. A 70B model in 16-bit numbers is about 140 GB.
Weight store to Chat lane GPUs
Spare GPU servers copy the weights to fast local disk and load them before taking traffic.
Router to Chat lane GPUs
The router sends a small share of traffic, for example 5%, to the new version.
Chat lane GPUs to Router
Latency and errors on that share are compared with the old version. If they are worse, the router moves the share back.
Read pathServe a chat request
- Team app
- Gateway
- Router
- Chat lane GPUs
- Usage metering
Team app to Gateway
A product team's app sends a prompt with its API key.
Gateway to Router
The gateway checks the key and the team's token quota, and marks the request as chat or batch.
Router to Chat lane GPUs
The router picks a chat GPU with room in its batch. It prefers one that already holds this system prompt in its cache.
Chat lane GPUs to Team app
The GPU reads the whole prompt first, then streams the answer one token at a time.
Chat lane GPUs to Usage metering
It reports the tokens in and out, so each team pays for what it used.
What breaks, and what happens then
One team sends a sudden spike
- What users see
- Other teams wait longer for their first token.
- What the design does
- Quotas and priority per team at the gateway. Batch work waits in its own lane.
A GPU server fails during an answer
- What users see
- That answer stops part way.
- What the design does
- The gateway retries on another GPU, and the answer starts again.
Long prompts fill GPU memory
- What users see
- New requests wait or are refused.
- What the design does
- The scheduler limits the tokens each GPU holds at once and queues the rest.
A new model version answers worse
- What users see
- Users in the small test share get worse answers.
- What the design does
- The share stays small until the comparison passes, and the router can move it back at once.
6. Deep dives
7. Follow-up questions
- One team suddenly sends ten times its usual traffic. What happens? (Its rate limit and token quota reject the extra with 429, so other teams' queues stay short; the platform alerts the team.)
- How do you release a new model version safely? (Load it beside the old one and send it a small share of traffic. Compare quality and latency on a fixed test set, then shift traffic in steps.)
What it costs
GPUs are the bill, and an idle GPU costs the same as a busy one. Batching more requests on each GPU lowers the cost per token. A separate, cheaper pool for jobs that can wait keeps the fast pool small.
Another way to design it
Teams could call a hosted model API and run no GPUs at all. That is cheaper at low or uneven volume, and there is nothing to operate. Running your own pays off with steady high volume, or with data that may not leave your network.
8. How answers are judged
A passing answer at Mid level. A complete design with numbers: about 700 requests a second at peak, about 210,000 output tokens a second. It explains batching and goes deep on one part, such as per-team quotas.
| What is judged | Junior | Mid | Senior | Staff |
|---|---|---|---|---|
| BreadthHow much of the system does the answer cover? | Names the core parts: clients, servers, a database and a cache. | Covers the whole main flow, from the request to the stored data and back. | Builds a complete design without being led through it. | Covers the system, the systems around it and who owns each part. |
| DepthHow far does it go into the hard parts? | Explains what each part does and why it is there. | Goes deep on one part, such as the database or the cache. | Goes deep on the two or three riskiest parts. | Goes deepest where the risk is largest, and explains why the risk is there. |
| DrivingWho leads the conversation? | Follows the interviewer, step by step. | Moves forward alone, with an occasional nudge. | Leads the conversation from start to finish. | Changes the problem when the question asked is not the right one. |
| Trade-offsAre choices compared and justified? | Names more than one option. | Says why one option was picked over another. | Compares options in detail, with what each one costs. | Ties each choice to cost, speed and risk for the business. |
| Unclear questionsWhat happens when the question is vague? | Answers the questions that are asked. | Asks questions to make the problem clear. | Sets the scope and says what is left out. | Questions the assumptions behind the problem itself. |
| ScopeWhat does it consider beyond the normal path? | Covers the normal path, when everything works. | Adds what happens when a part fails. | Adds growth: what breaks at ten times the load, and the fix. | Adds abuse, cost and the daily work of running the system. |
Requirements and scope
Before I design, I want to know who calls this and what they need. Chat needs first tokens within about half a second, while overnight batch jobs can wait. Each team needs a quota, so one team cannot starve the rest. Which models must we serve on day one?
Every request is a prompt in and an answer out. I will treat them all the same and serve them in order.
Shows: Unclear questionsThe difference: Chat and batch work have very different deadlines. Treating them the same makes people wait behind jobs that could have run later, more cheaply.
Estimates
20 million requests a day is about 230 a second, about 700 at peak. At 300 output tokens each, peak is about 210,000 tokens a second. An 8B model keeps about 128 kilobytes per token in GPU memory, so a 1,300-token request holds about 166 megabytes.
The model is 16 gigabytes and a GPU has 80. So each GPU holds five copies of the model and serves five requests at a time.
Shows: DepthThe difference: Memory goes to each request's keys and values, not to copies of the weights. One copy serves a few hundred requests at once.
Core design
A gateway checks each team's key and quota, then routes to that model's pool. Each GPU runs continuous batching: when one answer finishes, a waiting request takes its place right away. KV-cache memory is handed out in small pages, so an answer wastes at most one part-filled page.
Each GPU takes a batch of 32 requests, runs them together, and starts the next batch when all 32 have finished.
Shows: DepthThe difference: The batch waits for its longest answer, so most slots sit empty for most of the time. Continuous batching refills each slot as soon as it frees.
Deep dive
The hard part is scaling, because a new GPU must load gigabytes of weights before it serves anything. I would scale on queue length and time to first token, not GPU use, which stays high anyway. I would keep weights on local disk and hold a little warm spare capacity.
I would add GPUs when GPU utilisation goes above 80 percent and remove them when it falls below 30 percent.
Shows: DepthThe difference: A busy GPU is the goal, so utilisation stays high while users wait in the queue. Queue length and time to first token show the real pressure.
Failures and trade-offs
If the large model is overloaded, chat requests can fall back to the smaller model, and batch work waits. A team over its quota gets 429 with a retry time. If a GPU fails before any token is sent, the gateway retries once elsewhere. Mid-stream, the stream ends with a clear error.
If a GPU fails, the requests on it fail too, and the teams can retry if they want to.
Shows: Trade-offsThe difference: Many retries at once would land on the busiest pool. The platform should retry once itself and shed batch work first, protecting chat.
We wrote this guide in our own words, informed by public interview guides such as AlgoMaster and Hello Interview. We are not connected to either site. Interviewers differ. The guide and the example answers show the direction each level takes, not a checklist.
10. Check your design with your own AI
Write your design first. Then copy this prompt into the AI chat you already use, and add your design at the end. It asks for a score in each area, one fix for each, and two follow-up questions.
The site sends nothing anywhere. An AI review can be wrong, so check what it says against sections 8 and 9.
See the prompt
You are a system design interviewer. Review my design for the interview problem below. Problem: Design an LLM Inference Platform Serve several open language models to every product team through one API, with streaming, fair quotas and a cost per token you can predict. What users must be able to do: - One API for every team: send a prompt, choose a model, get the answer streamed back token by token. - Serve several models, such as a small fast one and a large accurate one, and add new versions safely. - Give each team a token quota and a rate limit, and report usage for billing. - Offer a cheaper batch lane for work that can wait, such as summarising yesterday's tickets. How well it must work: - Time to first token under about 0.5 s for 95 of every 100 chat requests (the p95). - At least 20 tokens a second for each streaming answer, faster than people read. - Keep GPUs busy, since they are the main cost. - One team's traffic spike must not slow the other teams down. Numbers to assume: - 20 million requests a day, with the busiest hour at about 3 times the average. - A typical request has about 1,000 prompt tokens and 300 output tokens. Judge my design at the Mid level. A passing answer at this level: A complete design with numbers: about 700 requests a second at peak, about 210,000 output tokens a second. It explains batching and goes deep on one part, such as per-team quotas. For each area below, say whether my design is strong, fine or weak. Give one reason and one fix for each: 1. Requirements and scope 2. Estimates 3. Core design 4. Deep dive 5. Failures and trade-offs Then ask me the two follow-up questions an interviewer would ask next. Do not write a full model answer for me. My design: [Describe your parts, how one request moves through them, and why you chose each one.]