Classic design · Staff
LLM service (ChatGPT)
Classic interview design. Key points: LLM serving (inference) and rate limiting algorithms.
Short answer
Classic interview design. Key points: LLM serving (inference) and rate limiting algorithms. The exercise asks for the system that serves a chat assistant: the user sends natural-language prompts and receives streamed responses from a large language model. Conversations are saved, and the user can return to an old chat and continue where they left off.
01 · CONTEXT
A chat on top of a model
The exercise asks for the system that serves a chat assistant: the user sends natural-language prompts and receives streamed responses from a large language model. Conversations are saved, and the user can return to an old chat and continue where they left off.
The prompt treats the model as a black box called by the system, without training it or operating its internals. The scope is text input and output only. Editing or branching existing messages is out of scope.
The two functional requirements are sending a prompt and receiving an AI-generated response, and viewing past chats to resume the conversation with the earlier context in the prompt.
02 · REQUIREMENTS
Latency, GPU, and cost
The interesting parts of the problem, according to the prompt, are streaming tokens fast, scheduling limited GPU capacity, and keeping cost under control as conversations grow.
| Eixo | What the prompt highlights |
|---|---|
| Latency | Latency to the first token matters more than total completion time. |
| Compute | GPUs are limited and expensive, so you need to be deliberate about who gets compute and when. |
| Custo | Cost has to stay under control as conversations grow. |
| Escopo | Text input and output only, no image, audio, or video. |
For scale, the prompt starts from a little over two hundred million daily active users. Its estimate yields about 20 thousand prompts per second at peak and about 120 thousand responses being generated at the same time.
03 · DESIGN
From prompt to token
In the design, the chat client sends the prompt through the API entry point.
In the design, the conversation service reads and updates the conversation store, which is where the chat context comes from.
In the design, the conversation service puts the request on a generation queue, which sits between it and the GPUs.
In the design, the GPU workers pull requests from the queue and call the model as a black box.
In the design, the generated tokens return to the conversation service and from there go on to the client.
The design separates the conversation service from the GPU workers with a generation queue. The tokens return in streaming to the client. The prompt says that latency to the first token matters more than total completion time.
The deep-dive questions in the next section cover how this path delivers tokens, survives reconnections, and uses the GPUs.
04 · DEEP DIVES
The remaining questions
The prompt lists five deep-dive questions, which serve as a study roadmap for this case.
| Aprofundamento | Question raised by the prompt |
|---|---|
| Streaming | How do you stream tokens back to the client? |
| Continuidade | How do you keep the stream alive across reconnections and deploys? |
| Escalonamento | How do you route and schedule generation requests among GPU workers? |
| Fairness across plans | How do you keep heavy users from dominating the GPU pool while still giving paid plans a better experience? |
| Cost in long conversations | How do you control inference cost without making the assistant seem forgetful? |
According to the guide, the patterns behind these LLM prompts are the same as in familiar distributed systems: queues, batching, load balancing, and asynchronous processing. The guide also recommends understanding how rate limiting works for LLM APIs.
In the design, a user's request arrives through the API entry point.
In the design, the entry point forwards the request to admission control before any queue.
In the design, admission control checks the user's usage counters.
In the design, only the accepted request enters the generation queue.
In the design, the GPU workers consume the queue and send metrics to monitoring.
The second design puts admission control before the queue, so that each user's consumption is measured before the request competes for GPU. This is a starting point for the question about heavy users and paid plans, not a ready-made answer.
The question about cost in long conversations connects to the discipline of cost and FinOps, and the one about scheduling the GPU, to the ML service.
Frequently asked questions
What is LLM service (ChatGPT)?
Classic interview design. Key points: LLM serving (inference) and rate limiting algorithms.
What does the LLM service (ChatGPT) design cover?
It is organized in these sections: A chat on top of a model, Latency, GPU, and cost, From prompt to token, and The remaining questions.
How long is LLM service (ChatGPT) and what level is it?
It takes about 17 minutes to read and is rated Staff level.
Now design it yourself
Run this case as an interview in the System Design school: you make the decisions, the tutor challenges them and you see how your design scores.