LearnThatStack Ace your next interview
AI Engineering

AI System Design.

Start free Change topic Change

Practise AI System Design one question at a time. Answer out loud or in writing, get graded, and see exactly what you missed.

Try one question

What does an "AI system design" interview round actually test, and how is it different from designing the model itself?

The answer

The round tests whether you can build a reliable product around a model you did not train. You treat the model as a remote dependency. It is paid per token, sometimes slow, and non-deterministic, so the same input can give different output.

Model design asks how to make the model better. System design asks what to do when it is wrong, slow, or down.

Designing the model Designing the system
What you work on Data, architecture, training loss Latency and cost budgets
How you measure it Offline benchmark scores Evals on live traffic
What you ship One artifact Retrieval, state, guardrails, fallbacks

Interviewers listen for numbers: cost per request, a latency target, and a plan for failure. Saying "just call the API" without those is the usual reason people fail.

Example · what grading looks like
What is time-to-first-token versus total latency, and why do both matter?

“Time to first token is how long the user stares at nothing before output starts, and total latency is how long until the response is completely done. They're driven by different things. Before anything comes out, the model has to read the whole input, so a big system prompt plus a stack of retrieved documents pushes the first token back, and so does sitting in the provider's queue. After that it produces tokens one at a time, so a long answer takes longer to finish even if it started quickly. Which one you care about depends on how the output gets used. In a chat window with streaming, people start reading straight away, so the first token is what makes it feel fast. But if the model is filling in a JSON form for a backend job or picking a function to call, half a response is useless, so what counts is when the last token lands.”

Knew it

Nails both metrics and their drivers, and correctly ties the choice to use case (streaming chat vs JSON/tool calls). Doesn't mention tracking both at p95 per route or that a fast first token can still hide a slow overall response.

Missed: Doesn't mention tracking both metrics at p95 per route rather than a single blended number.

Missed: Doesn't flag that a fast first token can still hide a slow overall response, which is the practical reason both matter together.


Get your own answers graded

Sign up free. Your account comes with 50 credits for grading, and it remembers what you missed.

What it covers

All 54 questions

Each on its own page

Architecture layers and hosting

What the round tests, the layers of a production LLM app, and when to use hosted APIs instead of running your own inference.

4 questions

  1. What does an "AI system design" interview round actually test, and how is it different from designing the model itself?
  2. What are the core architecture layers of a production LLM application?
  3. Build versus buy: hosted model APIs versus self-hosting. How do you decide? Pro
  4. When and how would you self-host LLM inference at scale (batching, KV cache, GPU autoscaling)? Pro

Conversation state and memory

Stateless model APIs, context window budgets, storing chat history, and memory for long-lived assistants and agents.

5 questions

  1. The LLM API is stateless. What does that mean for conversation design? Pro
  2. What is the context window, and how does it constrain system design? Pro
  3. Design a ChatGPT-style conversational assistant. Walk through the architecture. Pro
  4. How would you design conversation state and memory storage for a chat product? Pro
  5. Design the memory architecture for a long-lived agent that operates over days or weeks. Pro

Latency and streaming

Time to first token, streaming over SSE or WebSockets, latency budgets per stage, and real-time voice pipelines.

5 questions

  1. What is time-to-first-token versus total latency, and why do both matter?
  2. Why is streaming important for LLM UX, and what does it change about your architecture?
  3. How do you set and enforce a latency budget across an LLM request pipeline? Pro
  4. How do you architect streaming at scale (SSE/WebSockets), including load balancers and reconnection? Pro
  5. Design a real-time voice assistant: what is the end-to-end latency budget, and where does it break? Pro

Prompt and semantic caching

Prefix caching, exact-match and semantic caches, how to tune thresholds, and how to prevent wrong or stale hits.

5 questions

  1. What is prompt (prefix) caching, and why does it matter for cost and latency?
  2. What is the difference between exact-match caching and semantic caching? Pro
  3. Design a semantic cache. How does it work, and what breaks it? Pro
  4. How do you optimize prompt caching at scale: prefix design, invalidation, and hit rate? Pro
  5. Semantic caching correctness: how do you tune the threshold and prevent wrong or stale hits? Pro

Gateways and model routing

The LLM gateway as a single entry point, cheap-first cascades, and routing requests by cost, latency and quality.

4 questions

  1. What is an LLM gateway (or AI proxy), and what belongs in it?
  2. What is model routing, and what is a "cheap-first" cascade?
  3. Design a model routing layer. How do you decide which model handles a request? Pro
  4. How do you make routing decisions with evals to balance cost, latency, and quality? Pro

Cost modeling and budgets

What drives token cost, estimating cost per conversation, per-tenant budgets, and a standing cost optimization program.

4 questions

  1. What are the main cost drivers of an LLM system, and how do you reason about them? Pro
  2. How do you model and estimate the cost per conversation for an LLM product? Pro
  3. How do you enforce per-tenant cost controls and budgets, with hard and soft limits? Pro
  4. Design an end-to-end cost optimization program for a high-volume LLM product. Pro

Scaling, quotas and queueing

Async jobs, multi-tenant rate limits, handling 429s and backpressure, fair queueing, and capacity on a shared platform.

6 questions

  1. How would you handle long-running LLM jobs, like processing a 500-page document? Pro
  2. How do you handle multi-tenancy in an LLM platform: rate limiting, quotas, and noisy neighbors? Pro
  3. How do you scale LLM inference: autoscaling and load-balancing across providers and regions? Pro
  4. How do you handle provider rate limits (429s) and backpressure under load? Pro
  5. Design the queueing system for spiky, asynchronous LLM workloads with priorities and fairness. Pro
  6. Design a global, multi-tenant LLM platform serving many internal product teams. Cover capacity, quotas, and chargeback. Pro

Reliability and failover

Fallbacks, graceful degradation, active-active setups across regions and providers, and SLOs with error budgets.

4 questions

  1. What is a fallback, and why does every LLM system need one? Pro
  2. What does graceful degradation look like when a model provider is down or filters a request? Pro
  3. Design a multi-region, multi-provider active-active setup for high availability. Pro
  4. Define SLOs and a reliability strategy for an LLM system, including error budgets and a degradation ladder. Pro

RAG and grounded answers

Choosing RAG over fine-tuning or long context, access-controlled retrieval, answers with citations, and abstaining.

5 questions

  1. Design an AI customer support bot that answers from company documentation and can escalate to humans. Pro
  2. Design an enterprise RAG search system over internal documents with access control. Pro
  3. How do you design a system that grounds its answers and abstains instead of hallucinating? Pro
  4. How do you decide between RAG, fine-tuning, and long-context prompting when a model needs your private data? Pro
  5. Design a Perplexity-style answer engine that searches the web and cites its sources. Pro

Guardrails and data protection

Where guardrails go in the pipeline, layered defenses against prompt injection, and keeping PII away from hosted providers.

3 questions

  1. Where should guardrails live in the pipeline, and what are the tradeoffs of each placement? Pro
  2. How would you design layered defenses against prompt injection in RAG and agents? Pro
  3. How do you keep PII and regulated data out of third-party model providers while still using hosted APIs? Pro

Agents, tools and human review

Reliable structured output and tool calls, agent platforms and coding assistants, and human-in-the-loop review.

4 questions

  1. How would you design human-in-the-loop escalation and review? Pro
  2. Design an AI coding assistant (IDE autocomplete plus a chat/agent mode). Pro
  3. How do you get reliable structured output and tool calls from a model at scale: schemas, validation, and retry handling? Pro
  4. Design an AI agent platform: orchestration, tool registry, sandboxing, and reliability. Pro

Evals, observability and rollouts

Evals and monitoring, tracing and token accounting, shadow and canary rollouts, model migrations, and data flywheels.

5 questions

  1. What should you instrument for evals and monitoring in a production LLM system? Pro
  2. How do you safely roll out a prompt or model change using shadow traffic and canaries? Pro
  3. How would you design a data flywheel that improves the system over time? Pro
  4. Design end-to-end observability for a multi-step LLM request, including token accounting. Pro
  5. How do you safely handle provider model deprecations and migrations? Pro
Practice · Questions

All questions

Showing of 54
Beginner 12
01

What does an "AI system design" interview round actually test, and how is it different from designing the model itself?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

The round tests whether you can build a reliable product around a model you did not train. You treat the model as a remote dependency. It is paid per token, sometimes slow, and non-deterministic, so the same input can give different output.

Model design asks how to make the model better. System design asks what to do when it is wrong, slow, or down.

Designing the model Designing the system
What you work on Data, architecture, training loss Latency and cost budgets
How you measure it Offline benchmark scores Evals on live traffic
What you ship One artifact Retrieval, state, guardrails, fallbacks

Interviewers listen for numbers: cost per request, a latency target, and a plan for failure. Saying "just call the API" without those is the usual reason people fail.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

02

What are the core architecture layers of a production LLM application?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

A production LLM app is a normal web app plus two layers, orchestration and model access. The model is one dependency, not the system.

  • The client renders streamed output and holds the UI session.
  • The application API owns auth and business rules, and persists conversation history.
  • Orchestration builds each request from retrieval, templates and tool calls, and runs multi-step flows.
  • The data layer holds the vector index, documents and application database.
  • Model access talks to providers and holds their keys. It runs retries and timeouts, and tracks spend.
  • Providers are hosted APIs or self-hosted inference.

Safety checks, evals and telemetry are not a layer. They wrap every call.

These are logical layers, so start in one process. From day one, nothing outside model access imports a provider SDK.

// the only module that imports a provider SDK
export async function complete({ model, messages }) {
  return client.messages.create({ model, messages, max_tokens: 1024 });
}
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

03

What is time-to-first-token versus total latency, and why do both matter?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Time-to-first-token (TTFT) is the wait from sending the request until the first token comes back. Total latency is the wait until the last token arrives.

Roughly, total = TTFT + output_tokens * time_per_output_token.

TTFT depends on prompt length, queue wait and prefill, the pass that reads the whole prompt before generating. It is what the user feels in streamed chat. Total latency depends on the number of output tokens and decode speed. It matters for JSON, tool calls and batch jobs, where nothing is usable early.

The two move independently. Trimming the prompt cuts TTFT. Trimming the answer cuts total latency.

So track both at p95, per route. A fast first token followed by a slow 800-token answer still fails a voice agent. One blended number hides which half is broken.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

04

Why is streaming important for LLM UX, and what does it change about your architecture?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Streaming sends tokens as the model writes them, so the user reads the first words in under a second, not a spinner. Total time barely changes. The wait just feels shorter.

It changes the architecture because the reply stops being one JSON object. You hold a connection open, usually with Server-Sent Events (SSE), a one-way stream over HTTP. Every hop must forward chunks without buffering, and proxies, gzip and gateways buffer by default.

The HTTP status goes out before the answer exists. So a mid-stream failure needs an in-band error event, not a 500. Token counts also arrive last, so keep a copy of the stream on the server for logging, caching and output checks.

let full = '';
for await (const chunk of stream) {
  full += chunk.delta;                       // server-side copy
  res.write(`data: ${JSON.stringify(chunk)}\n\n`);
}
res.write(`event: done\ndata: ${JSON.stringify(usage)}\n\n`);
await logAndCache(full);                     // only possible after the last chunk

If the user stops a bad answer, abort the upstream call. Otherwise you pay for tokens nobody ever sees.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

05

What is prompt (prefix) caching, and why does it matter for cost and latency?

Visual

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain
Visual

Prompt caching stores the model's internal state for a prompt prefix, its KV cache, so a later request with the same prefix skips recomputing it. The match is prefix-based from the first token, so put stable parts first and the changing user turn last. One edited character early invalidates everything after it.

// Anthropic-style: mark where the stable prefix ends
const req = {
  system: [
    { type: 'text', text: instructions + toolDocs,
      cache_control: { type: 'ephemeral' } }      // cache up to here
  ],
  messages: [{ role: 'user', content: userTurn }] // changes every call
};

Cost falls because cached tokens are read back at a steep discount. Writing the cache can cost more than plain input, so it pays off only on repeats. Providers also set a minimum prefix size, so short prompts never cache.

Latency falls because caching shortens prefill, the pass over the input before the first output token. Time-to-first-token drops, but generation speed is unchanged. Entries usually expire after minutes of inactivity, so repeated, bursty traffic gains most.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

06

What is an LLM gateway (or AI proxy), and what belongs in it?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

An LLM gateway, or AI proxy, is one internal service that every app calls instead of calling model providers directly. It is a reverse proxy for model traffic, so cross-cutting concerns live in one place.

// app code: one endpoint, provider-shaped body, no provider keys
const res = await fetch('https://gateway.internal/v1/messages', {
  method: 'POST',
  headers: { 'x-tenant-id': tenantId, 'x-trace-id': traceId },
  body: JSON.stringify({ model: 'claude-sonnet-4-6', messages, stream: true })
});

The gateway owns:

  • provider keys and caller auth, so no key sits in app code
  • per-tenant rate limits and quotas
  • retries, timeouts and failover
  • trace IDs, token accounting and request logs, so usage is measured once

Prompt templates, retrieval and business logic stay in the app. So do conversation state and response rendering.

Keep it thin. It sits on the hot path of every request, so it must pass streamed chunks through untouched. It is also a single point of failure, so it needs health checks and a bypass path.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

07

What is model routing, and what is a "cheap-first" cascade?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Model routing sends each request to the model that fits what the request needs. Small, cheap models handle easy work, and large models handle the hard cases. The router decides before the call, using rules, request length or a small classifier.

A cheap-first cascade decides after the fact instead. You always call the cheap model first and check its answer. You escalate to the stronger model only when that check fails.

async function cascade(prompt) {
  const draft = await call('small-model', prompt);
  if (passesCheck(draft)) return draft;   // most traffic stops here
  return call('large-model', prompt);     // escalation pays twice
}

The tradeoff is that an escalated request pays for both calls and both latencies. A cascade saves money only while the escalation rate stays low. The check must also be cheap, because a check that calls a big model to grade defeats the point.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

08

The LLM API is stateless. What does that mean for conversation design?

Part of Pro
09

What is the context window, and how does it constrain system design?

Part of Pro
10

What is the difference between exact-match caching and semantic caching?

Part of Pro
11

What is a fallback, and why does every LLM system need one?

Part of Pro
12

What are the main cost drivers of an LLM system, and how do you reason about them?

Part of Pro
Intermediate 21
13

Design a ChatGPT-style conversational assistant. Walk through the architecture.

Part of Pro
14

Design an AI customer support bot that answers from company documentation and can escalate to humans.

Part of Pro
15

How would you handle long-running LLM jobs, like processing a 500-page document?

Part of Pro
16

Design a semantic cache. How does it work, and what breaks it?

Part of Pro
17

Design a model routing layer. How do you decide which model handles a request?

Part of Pro
18

How do you handle multi-tenancy in an LLM platform: rate limiting, quotas, and noisy neighbors?

Part of Pro
19

How would you design conversation state and memory storage for a chat product?

Part of Pro Visual
20

How do you set and enforce a latency budget across an LLM request pipeline?

Part of Pro
21

Where should guardrails live in the pipeline, and what are the tradeoffs of each placement?

Part of Pro
22

Design an enterprise RAG search system over internal documents with access control.

Part of Pro Visual
23

How do you scale LLM inference: autoscaling and load-balancing across providers and regions?

Part of Pro
24

How do you model and estimate the cost per conversation for an LLM product?

Part of Pro Visual
25

What does graceful degradation look like when a model provider is down or filters a request?

Part of Pro
26

What should you instrument for evals and monitoring in a production LLM system?

Part of Pro
27

How would you design human-in-the-loop escalation and review?

Part of Pro
28

Build versus buy: hosted model APIs versus self-hosting. How do you decide?

Part of Pro
29

How do you handle provider rate limits (429s) and backpressure under load?

Part of Pro
30

Design an AI coding assistant (IDE autocomplete plus a chat/agent mode).

Part of Pro
31

How do you design a system that grounds its answers and abstains instead of hallucinating?

Part of Pro
32

How do you get reliable structured output and tool calls from a model at scale: schemas, validation, and retry handling?

Part of Pro
33

How do you decide between RAG, fine-tuning, and long-context prompting when a model needs your private data?

Part of Pro
Expert 21
34

Design a multi-region, multi-provider active-active setup for high availability.

Part of Pro
35

How do you optimize prompt caching at scale: prefix design, invalidation, and hit rate?

Part of Pro
36

How do you enforce per-tenant cost controls and budgets, with hard and soft limits?

Part of Pro
37

Design an AI agent platform: orchestration, tool registry, sandboxing, and reliability.

Part of Pro
38

How do you safely roll out a prompt or model change using shadow traffic and canaries?

Part of Pro
39

How would you design a data flywheel that improves the system over time?

Part of Pro
40

Semantic caching correctness: how do you tune the threshold and prevent wrong or stale hits?

Part of Pro
41

Design the queueing system for spiky, asynchronous LLM workloads with priorities and fairness.

Part of Pro Visual
42

How do you architect streaming at scale (SSE/WebSockets), including load balancers and reconnection?

Part of Pro Visual
43

Design the memory architecture for a long-lived agent that operates over days or weeks.

Part of Pro
44

How would you design layered defenses against prompt injection in RAG and agents?

Part of Pro
45

Design end-to-end observability for a multi-step LLM request, including token accounting.

Part of Pro Visual
46

How do you make routing decisions with evals to balance cost, latency, and quality?

Part of Pro
47

How do you safely handle provider model deprecations and migrations?

Part of Pro
48

Design a global, multi-tenant LLM platform serving many internal product teams. Cover capacity, quotas, and chargeback.

Part of Pro
49

Define SLOs and a reliability strategy for an LLM system, including error budgets and a degradation ladder.

Part of Pro
50

Design an end-to-end cost optimization program for a high-volume LLM product.

Part of Pro
51

When and how would you self-host LLM inference at scale (batching, KV cache, GPU autoscaling)?

Part of Pro Visual
52

Design a real-time voice assistant: what is the end-to-end latency budget, and where does it break?

Part of Pro Visual
53

How do you keep PII and regulated data out of third-party model providers while still using hosted APIs?

Part of Pro
54

Design a Perplexity-style answer engine that searches the web and cites its sources.

Part of Pro

No matches

Try a different filter or search term.

Know someone prepping for AI System Design? Send them this set.
Quick recap

AI System Design in pictures.

A quick recap of AI System Design in 42 short animated pictures, one idea at a time. About 11 min to get the whole topic back in your head before you walk in. Pause any picture, slow it down, or step through it.

Pro The first chapter is free to play. The other 38 pictures come with Pro.

Get Pro · $10/mo
Pro · $10/mo

47 of 54 AI System Design answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime

Change topic

Pick a different technology or stack. Your current topic stays put until you choose a new one.

Technologies
No technologies match “”.
Cross-cutting topics
No topics match “”.
By role
Stacks & frameworks

MEAN

MongoDB, Express, Angular, Node.js

MERN

MongoDB, Express, React, Node.js

LAMP

Linux, Apache, MySQL, PHP

Django

Python Full-Stack Development

Ruby on Rails

Convention over Configuration

Serverless on AWS

Serverless Architecture on AWS

Flutter Mobile

Flutter Cross-Platform Mobile Development

Spring Boot

Enterprise Java Development

.NET

Microsoft Ecosystem

Vue

Vue.js, Vite, TypeScript, Tailwind, Node.js

Go Backend

Golang, gRPC, PostgreSQL, Redis, RabbitMQ

FastAPI

Python, FastAPI, SQLAlchemy, PostgreSQL

React Native

React, TypeScript, Redux, Firebase

iOS Native

Swift, SwiftUI, UIKit, Firebase

Android Native

Java, Jetpack Compose, Firebase

DevOps / Platform

Docker, Kubernetes, Terraform, CI/CD

AI Engineer

LLMs, RAG, Agents, Evals

AI-Powered Developer

Claude Code, Copilot, Agentic Workflows

Core SWE Interview Prep

Data structures, algorithms, OS, concurrency, networking, git