Skip to main content

Classic design · Staff

LLM service (ChatGPT)

Classic interview design. Key points: LLM serving (inference) and rate limiting algorithms.

17 min read · Content reviewed on October 23, 2026

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.

EixoWhat the prompt highlights
LatencyLatency to the first token matters more than total completion time.
ComputeGPUs are limited and expensive, so you need to be deliberate about who gets compute and when.
CustoCost has to stay under control as conversations grow.
EscopoText 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

  1. In the design, the chat client sends the prompt through the API entry point.

    Architecture diagram: LLM chat service
    CLChat clientprompt
    NWAPI entry point
    CPConversation service
    DBConversation store
    QGeneration queue
    CPGPU workers
  2. In the design, the conversation service reads and updates the conversation store, which is where the chat context comes from.

    Architecture diagram: LLM chat service
    CLChat client
    NWAPI entry point
    CPConversation service
    DBConversation storehistory
    QGeneration queue
    CPGPU workers
  3. In the design, the conversation service puts the request on a generation queue, which sits between it and the GPUs.

    Architecture diagram: LLM chat service
    CLChat client
    NWAPI entry point
    CPConversation service
    DBConversation store
    QGeneration queuegeneration request
    CPGPU workers
  4. In the design, the GPU workers pull requests from the queue and call the model as a black box.

    Architecture diagram: LLM chat service
    CLChat client
    NWAPI entry point
    CPConversation service
    DBConversation store
    QGeneration queue
    CPGPU workerscaixa-preta
  5. In the design, the generated tokens return to the conversation service and from there go on to the client.

    Architecture diagram: LLM chat service
    CLChat clienttokens
    NWAPI entry point
    CPConversation service
    DBConversation store
    QGeneration queue
    CPGPU workers

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.

AprofundamentoQuestion raised by the prompt
StreamingHow do you stream tokens back to the client?
ContinuidadeHow do you keep the stream alive across reconnections and deploys?
EscalonamentoHow do you route and schedule generation requests among GPU workers?
Fairness across plansHow do you keep heavy users from dominating the GPU pool while still giving paid plans a better experience?
Cost in long conversationsHow 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.

  1. In the design, a user's request arrives through the API entry point.

    Architecture diagram: Admission and limits in front of the GPUs
    CLClientpedido
    NWAPI entry point
    CPAdmission control
    CHUsage counters
    QGeneration queue
    CPGPU workers
    NWMonitoramento
  2. In the design, the entry point forwards the request to admission control before any queue.

    Architecture diagram: Admission and limits in front of the GPUs
    CLClient
    NWAPI entry point
    CPAdmission controladmission
    CHUsage counters
    QGeneration queue
    CPGPU workers
    NWMonitoramento
  3. In the design, admission control checks the user's usage counters.

    Architecture diagram: Admission and limits in front of the GPUs
    CLClient
    NWAPI entry point
    CPAdmission control
    CHUsage countersrecent usage
    QGeneration queue
    CPGPU workers
    NWMonitoramento
  4. In the design, only the accepted request enters the generation queue.

    Architecture diagram: Admission and limits in front of the GPUs
    CLClient
    NWAPI entry point
    CPAdmission control
    CHUsage counters
    QGeneration queueaceito
    CPGPU workers
    NWMonitoramento
  5. In the design, the GPU workers consume the queue and send metrics to monitoring.

    Architecture diagram: Admission and limits in front of the GPUs
    CLClient
    NWAPI entry point
    CPAdmission control
    CHUsage counters
    QGeneration queue
    CPGPU workers
    NWMonitoramentometrics

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.