LLM System Design · Module 17 of 17 · 10 concepts · about 16 min

The LLM System Design Interview

How to answer LLM system design questions: a structure, the numbers to estimate, the trade-offs to name, two worked designs, and the most frequently asked questions with the answer each one is looking for.

At work: Interviews for AI engineer, ML engineer and platform roles, where 'design a chat assistant' or 'design an LLM gateway' is now a standard system design round.

A framework for LLM system design questions

What it is

Answer a design question in a fixed order:

  • 1. Clarify the requirements: users, volume, latency, quality, cost, safety.
  • 2. Estimate the scale: requests, tokens per minute, cost.
  • 3. Sketch the request path: the eight stages from application to logging.
  • 4. Go deep on the two or three decisions that matter most for this system.
  • 5. Reliability: what happens when the model is slow, down or rate-limited.
  • 6. Safety and evaluation: guardrails, test sets, release gates.
  • 7. Operations: cost tracking, monitoring, how changes are rolled out.

Why it matters

Interviewers grade structure as much as content.

  • A candidate who starts by naming a model has skipped the questions that decide which model is right.
  • Following the order shows you can run a project, and it guarantees you reach reliability, safety and evaluation, the three areas most often left out and the ones senior interviewers care about most.

In the real world: A candidate who spends two minutes on requirements, draws the request path, and reaches fallbacks and evaluation unprompted is rated above one who gives a longer, unstructured tour of model internals.

Visual example

Interview

Roughly five minutes each. Do not skip the first two or the last three.

The order of an LLM system design answer

  1. ClarifyVolume, latency, quality, cost, safety
  2. EstimateTokens per minute, cost per day
  3. SketchGuardrails to logging
  4. Deep divesThe two or three key decisions
  5. ReliabilityTimeouts, retries, fallbacks
  6. Safety and evaluationGuardrails, test set, gate
  7. OperationsCost, monitoring, rollout

Spending the whole interview on the model and the prompt. Leave time for the last three steps. If time is short, say in one sentence each what you would do for reliability, safety and evaluation.

Clarifying requirements

What it is

The questions to ask before drawing anything:

  • Who uses it, and how much? Users, requests per day, the peak.
  • Is someone waiting? A live chat, or work that can run later?
  • How fast? A target for the first word and for the whole answer.
  • How good must it be? What does a wrong answer cost?
  • What may it do? Only answer, or also take actions?
  • What data is involved? Personal data, rules about where it may go.
  • What is the budget? Per request or per month.

Why it matters

Each answer changes the design.

  • A live chat means streaming and a tight latency budget.
  • Actions mean tool calling with permission checks. Personal data may rule out some providers.
  • A high cost of error means verification and a route to a human.
  • Asking shows you know which facts drive which decisions.

In the real world: Told that 'the assistant can cancel orders', a strong candidate immediately brings in idempotency keys, a confirmation step and an audit log.

Visual example

Requirements

Ask the question, then state the consequence.

Each requirement and the design decision it drives
ask aboutit decides
Live or offlineStreaming and latency budget, or batch and queues
Volume and peakTokens per minute, quotas, routing, cost
Cost of a wrong answerVerification, human handover, depth of evaluation
Answers only, or actionsTool calling, permissions, idempotency, approval
Kind of dataAllowed providers, masking, logging rules
BudgetModel tier, caching, prompt size
Behaviour when the model is downFallback chain and degraded mode

Asking a list of questions and then ignoring the answers. After each one, say what it changes: 'it takes actions on accounts, so permissions will be enforced in the tools and large actions will need approval.'

Back-of-the-envelope numbers

What it is

Five quick estimates, in order:

  • requests per day = users × messages per user;
  • average and peak requests per second;
  • tokens per minute at peak = peak requests per second × 60 × tokens per request;
  • streams open at once = peak requests per second × seconds per answer;
  • cost per day = requests × cost per request.

Why it matters

Estimates turn opinions into decisions.

  • Tokens per minute says whether one provider's quota is enough. Open streams sizes your own servers.
  • Cost per day says whether the largest model is affordable, and usually shows it is not, which leads naturally to routing and caching.
  • Being roughly right, quickly, with the working shown, is what is being tested.

In the real world: Asked whether the design is affordable, a candidate works out the daily cost on the whiteboard, sees it is too high, and proposes routing easy messages to a small model, all in under two minutes.

Visual example

Computed

Sizing a chat assistant with 1 million daily users sending 8 messages each, on the medium tier.

3,000 tokens in and 300 out per message; peak 3× the average; example prices
quantityworkingresult
Requests per day1 million × 88 million
Average requests per second8 million ÷ 86,40093
Peak requests per second93 × 3278
Tokens per minute at peak278 × 60 × 3,30055 million
Streams open at once, at peak278 × 4.4 seconds1,208
Cost per request3,000 in, 300 out₹1.13
Cost per day₹1.13 × 8 million₹90 lakh

Conclusion to state aloud: the token rate needs several providers or reserved capacity, and the daily cost makes routing and caching necessary, not optional.

Chasing precision. Round freely and say your assumptions aloud. 'About 90 requests a second on average, call it 280 at peak' in twenty seconds beats an exact figure in three minutes.

The trade-offs to name

What it is

Most choices in an LLM system trade two things, and interviewers want both sides named:

  • Model size: quality against cost and latency.
  • Context size: more information against cost, speed and focus.
  • Streaming: perceived speed against the ability to check the whole answer first.
  • Caching: speed and cost against freshness.
  • Guardrails: safety against latency and blocked legitimate requests.
  • Retries: reliability against added delay and load.
  • Hosted or self-hosted: simplicity against control and cost at scale.
  • Autonomy: usefulness against the risk of wrong actions.

Why it matters

A choice stated without its cost sounds like a habit.

  • A choice stated with its cost, and with the measurement that would settle it, sounds like engineering.
  • The pattern for any trade-off answer is: the two sides, what you would pick by default, and what you would measure to check.

In the real world: Asked 'would you stream?', a strong candidate answers 'yes for the chat, with a one-sentence buffer for output checks; no for the extraction endpoint, where a program needs the whole result'.

Visual example

Trade-offs

Name both sides, pick a default, say what you would measure.

Eight trade-offs, each with its two sides
decisiongainscostssettle it by measuring
Larger modelQualityCost, latencyTest-set score per rupee
More contextInformationCost, focusQuality against tokens sent
StreamingPerceived speedHarder output checksTime to first word
Response cachingCost, speedFreshnessHit rate, wrong-hit rate
Stricter guardrailsSafetyLatency, false blocksBoth error rates
More retriesSuccess rateDelay, loadp95 latency during failures
Self-hostingControl, cost at scaleOperations workUtilisation
More autonomyUsefulnessRisk of wrong actionsError rate on actions

Answering 'it depends' and stopping. Say what it depends on, then commit: 'it depends on how much of the traffic is easy; I would start with static routing per feature and measure the share before adding a per-request router.'

Worked design: a ChatGPT-like application

What it is

The most common question. The points an interviewer wants to hear, in order:

  • Streaming over server-sent events, with cancellation when the user leaves.
  • Conversations stored per message with a parent, so edits and regenerations form a tree.
  • Context management: a token budget, recent turns in full, older ones summarised.
  • Prompt caching for the unchanging start of the prompt.
  • Model tiering: a small model for titles and easy turns, a larger one for hard turns.
  • Guardrails on input and on the streamed output.
  • Fallback to another provider on timeout, behind a gateway.
  • Limits per user, in tokens, and a cost budget.

Why it matters

Each point answers a follow-up the interviewer is likely to ask: how does the user see words appear, what happens to a long chat, what happens when the provider is down, how is one abusive user stopped. Stating them in this order shows the request path, then the state, then the failure handling, which is the natural shape of the system.

In the real world: A candidate who volunteers 'and when the provider times out before the first token, the gateway falls back to a second model' answers the interviewer's next question before it is asked.

Visual example

Worked design

The whole path. Storage and fallback are the parts candidates forget.

One message through a chat application

  1. ReceiveAuthenticate; token limit
  2. Input checksScope, attacks, personal data
  3. Load contextSummary + recent turns
  4. Build promptUnchanging part first, for caching
  5. GatewayPick tier; timeout; fall back
  6. StreamTokens as events, checked as they go
  7. StoreAnswer with parent and tokens
  8. Meter and logCost to the user; trace

Describing only the happy path. The differentiating part of this question is the long conversation, the provider outage and the abusive user. Reach them without being asked.

Practise it: Design a ChatGPT-like Application

Worked design: an LLM gateway

What it is

The platform version of the question. The points to cover:

  • One request format for callers, with an adapter per provider.
  • Model aliases, mapped to pinned versions, with weighted rollout.
  • Virtual keys per team, holding limits and budgets; provider keys stay inside.
  • Rate limits in tokens per minute, with a token bucket in a shared store.
  • Reliability: timeouts, retries with backoff and jitter, circuit breakers, fallback chains.
  • Streaming passed through and normalised across providers.
  • Metering: tokens and cost per team and feature, from the provider's own counts.
  • Logging off the request path, with rules for sensitive content.
  • The gateway itself: stateless copies, a few milliseconds of overhead, fails open where safe.

Why it matters

This question tests whether you see the gateway as a reliability and cost product, not a simple proxy. The interviewer will press on its failure modes: what happens if the limit store is down, if a provider streams a malformed chunk, if a budget runs out mid-conversation. Have an answer for each.

In the real world: Asked what the gateway does when its counter store is unreachable, a strong candidate says 'fall back to an approximate local limit and alert, because refusing every request would be worse'.

Designing a pass-through that only forwards requests. The value is in everything around the forwarding. A design with no limits, no fallbacks and no cost attribution has missed the point of the question.

Practise it: Design an LLM Gateway

Common questions: fundamentals and cost

What it is

The questions that open most interviews. They test whether you can explain the basics plainly and reason about money.

Why it matters

A crisp answer here earns the right to the harder questions. Each answer below is the two or three sentences an interviewer is listening for; the detail is in the earlier modules.

In the real world: A phone screen opens with 'why is your chatbot's bill higher than you estimated?'; the candidates who progress talk about input tokens and resent history, not about model choice alone.

Q: How is an LLM system different from a normal backend?

The core call is slow, priced per token, not repeatable, can be confidently wrong, and can be steered by its input. Those five properties drive streaming, budgets, evaluation by test set, verification and guardrails.

Q: What is a token, and why does it matter?

A piece of a word; about three quarters of an English word. Cost, speed, context limits and rate limits are all counted in tokens, so estimating tokens is how you estimate everything else.

Q: Why do long chats get slow and expensive?

The model has no memory, so the whole history is resent every turn. Input grows each turn. The fix is a token budget: recent turns in full, older ones summarised.

Q: How would you cut the cost of a feature?

In order: use the smallest model that passes the test set and route easy requests to it; send less context; cap the output; use prompt caching; cache repeated requests; batch offline work. Measure quality after each.

Q: When would you self-host a model?

When data may not leave your systems, or when volume is high and steady enough to keep GPUs busy. Otherwise a hosted API is cheaper and far less work.

Q: Prompting, retrieval or fine-tuning?

Prompting first. Retrieval when the model lacks the facts. Fine-tuning for a consistent style or to make a small model match a large one on one task.

Answering a cost question without numbers. Give the formula and a rough figure: requests times tokens times price. An answer in rupees is far more convincing than a list of techniques.

Practise it: Design a ChatGPT-like Application, Design an LLM Gateway

Common questions: latency, reliability and scale

What it is

The middle of the interview, where the interviewer checks that you have run one of these under real load.

Why it matters

These are the questions with the most room to show depth, so tie each answer to a failure it prevents.

In the real world: An on-site interviewer follows 'I'd fall back to another provider' with 'has that fallback ever been used?'; the candidate who answers 'I'd keep a small share of live traffic on it' passes that round.

Q: How do you make a slow model feel fast?

Stream the answer so the user reads while it is written; keep everything before the model call short and in parallel; ask for shorter answers; use a smaller model where it is good enough.

Q: What happens when the provider is down?

A first-token timeout, a few retries with backoff and jitter, then a fallback chain to another region or provider, with a circuit breaker so failing routes are skipped. If all fail, degrade to a non-AI experience.

Q: How do you handle rate limits?

Plan capacity in tokens per minute. Limit each caller with a token bucket at the gateway. On a 429, back off and use another route. Move offline work to queues and batch.

Q: Why retries with jitter?

Without it, every client retries at the same instant and the retries arrive as a wave that knocks the provider over again. Jitter spreads them out.

Q: How do you size the system?

Requests per day, then peak requests per second, then tokens per minute at peak and streams open at once. Compare the token rate with the provider's quota, and add headroom.

Q: What makes self-hosted serving efficient?

Continuous batching, which keeps the GPU full; quantization, which fits the model on cheaper hardware; and keeping utilisation high. Memory for in-flight requests is often the real limit.

Q: What would you cache?

Always the unchanging start of the prompt, with the provider's prompt cache. Whole responses only where requests repeat and do not depend on the user, with the model, prompt version and permissions in the key.

Saying 'I would add retries' as the whole reliability answer. Retries without backoff, a cap, a fallback and idempotent tools make an outage worse and can double an action.

Practise it: Design an LLM Inference Serving System

Common questions: safety, evaluation and operations

What it is

The questions that distinguish someone who has shipped an LLM feature from someone who has built a demo.

Why it matters

Senior interviews spend most of their time here. The answers come back to two habits: enforce what matters in code, and measure before and after every change.

In the real world: A hiring manager asks every candidate how they would know a prompt change made things worse; those who describe a test set, a per-category comparison and a release gate get offers.

Q: How do you defend against prompt injection?

Assume it will sometimes succeed. Separate outside content from instructions, give the model the fewest tools and least data it needs, enforce permissions inside the tools, and require confirmation for risky actions.

Q: How do you stop the assistant doing something it should not?

Not with the prompt. Identity comes from the session, every tool checks permission and limits in code, irreversible actions carry an idempotency key, and large ones need a person's approval.

Q: How do you evaluate a system whose answers vary?

A regression test set from real traffic; assertions in code for everything checkable; a model judge with a rubric, checked against human grades, for the rest; then shadow traffic and A/B tests on outcomes.

Q: How do you ship a prompt or model change safely?

Version it, run the test set against production's version, block on a drop in any category, canary to a small share, watch quality, cost and speed, then promote or roll back.

Q: What do you monitor?

Latency at p95, error and fallback rates, tokens and cost per feature, cache hit rate, guardrail blocks, and sampled quality. Quality and cost get alerts, not only uptime.

Q: How do you handle personal data?

Mask what the model does not need, check which providers the data may go to, classify what is logged, set retention, and make sure a deletion reaches every store that holds a copy.

Q: A user reports a wrong answer. What do you do?

Pull the trace. See what was retrieved, which prompt version and model answered, whether it fell back. Fix the stage that failed, and add the case to the test set.

Answering 'how do you evaluate?' with 'we would look at some outputs'. The follow-up will be 'and how do you know the next change did not break something?', which needs a test set and a gate.

Practise it: Design a ChatGPT-like Application, Design an LLM Evaluation Platform

Red flags interviewers listen for

What it is

Statements that signal a candidate has only built a demo:

  • Naming a model first, before asking what the system is for.
  • The largest model for everything, with no mention of cost.
  • No streaming for a live chat.
  • 'The prompt will tell it not to' as a safety measure.
  • No plan for provider failure.
  • No evaluation, or 'we will try some examples'.
  • No numbers: no token, capacity or cost estimate.
  • Every technique at once, with no reason for any of them.

Why it matters

Each has a positive counterpart, and together they describe a strong answer: requirements first, the smallest model that works, streaming with a latency budget, enforcement in code, a fallback chain, a test set with a release gate, estimates in tokens and rupees, and complexity added only where a stated need justifies it.

In the real world: Two candidates propose similar designs; the one who adds 'here is what it costs per day, and here is what I would cut first' is hired at the higher level.

Visual example

Signals

The right-hand column is a checklist for your own answer.

The red flag and the answer that replaces it
red flagsay this instead
'I'd use the biggest model''The smallest model that passes the test set, with routing for hard cases'
No mention of costRequests × tokens × price, in rupees per day
'The prompt tells it not to'Permissions and limits enforced in the tool's code
One provider, no fallbackTimeout, retries with jitter, fallback chain, circuit breaker
'We'd check a few answers'A regression set, a checked judge, and a release gate
Wait for the full answerStream, with a budget for time to first word
Everything in the contextA token budget: recent turns, a summary, the best passages
Agents and caches everywhereA simple baseline, then what a measured need requires

Overcorrecting into buzzwords. A design with agents, a semantic cache, a fine-tuned router and three guardrail models for a simple FAQ assistant is its own red flag. Start simple and justify each addition.