System Design interview questions: AI system architecture practice
Reviewed by Mark Dickie · Last updated
AI system design is the practice of architecting applications that train, serve, and scale machine-learning models alongside traditional distributed-system concerns like latency, throughput, and fault tolerance. For interviews in this area, you should know how to estimate compute and storage for ML workloads, choose between batch and real-time inference patterns, and reason about model serving infrastructure (GPU scheduling, model registries, autoscaling). You should also be able to trade off consistency vs. availability for feature stores, and explain how data drift triggers retraining pipelines.
The quiz below covers these topics at a range of difficulties. Each question mirrors the format used in real interviews at companies building large-scale ML platforms.
What does an AI system design interview test?
Interviewers expect you to move from high-level architecture to concrete numbers and component choices. They look for a structured approach: clarifying requirements, sketching a block diagram, sizing the system, and defending trade-offs. The table below maps the core areas to what you should be able to discuss on a whiteboard.
| Area | What the interviewer probes |
|---|---|
| Requirement clarification | Functional vs. non-functional goals, SLA targets, expected QPS, data volume |
| Capacity estimation | GPU-hours, model size in GB, inference latency budget, storage for training data |
| Model serving | Batch vs. online inference, model registry, versioning, A/B rollout, autoscaling on GPU pools |
| Data pipeline | Feature store design, online vs. offline features, CDC, schema evolution |
| Monitoring & drift | Prediction logging, data-drift detection, alerting, retraining triggers |
| Fault tolerance | Replica failover, degraded-mode serving, checkpointing for long training jobs |
How should you structure your answer?
- Restate the problem and confirm scope — name the users, the scale, and the latency target before drawing anything.
- Sketch the end-to-end data flow: ingestion, feature engineering, training, model registry, serving, and monitoring.
- Put real numbers on the board — QPS, model size, GPU memory, network bandwidth. Round orders of magnitude are fine.
- Identify the bottleneck (usually GPU at inference time or I/O during training) and propose a mitigation: batching, quantization, or distillation.
- Close with failure modes and the monitoring that catches them: drift, latency spikes, dead replicas.
What are the most common pitfalls?
Candidates lose points by jumping into the diagram before sizing the system, or by hand-waving the GPU layer. Treat model serving as a first-class capacity problem: a 7-billion-parameter model at fp16 needs roughly 14 GB of GPU memory before you serve a single request, and that constraint shapes everything downstream — batching strategy, replica count, and autoscaling thresholds. Another frequent miss is ignoring the feedback loop: if you cannot detect drift, you cannot justify when retraining fires, and the system silently degrades.
Key facts
- Tarmac has 27 System Design interview questions on this topic, 10 of them on this page, at difficulty 3–5 of 5.
- Tarmac tracked 4,937 job postings asking for System Design in August 2026.
- Roles asking for System Design advertise a median base salary of US$182,500, across 971 job postings as of August 2026.
- Tarmac last reviewed these System Design interview questions on 31 August 2026.
At a glance
| Questions | 10 shown · 27 in the bank |
|---|---|
| Difficulty | 3–5 of 5 |
| Formats | Multiple choice, True / false, Short answer, Flashcard, Multiple answer, Ordering, Design exercise |
What you'll review
- ai system design
Practice questions
Try one before you open the answer. Pick an option and press Check; it's marked on the spot.
System Design/sd-architecture/ai-system-design
You operate a customer-facing endpoint backed by an LLM. The model inference call dominates both p95 latency and per-request cost. Which combination of system-level techniques most directly attacks both at once?#
Options
Show answer
Combine three system-level levers: stream tokens over SSE to cut time-to-first-token, cache responses to repeated or similar prompts to skip inference entirely, and route simple requests to a small model while escalating only when needed. These change how often you invoke the model, which model you invoke, and how you deliver the result. Adding replicas, blanket CDN caching, or raising the output token limit each fail here.
The inference call is the lever, so the wins come from changing how often you invoke it, which model you invoke, and how you deliver the result. Streaming (SSE) doesn't speed up total generation but slashes perceived latency by showing the first tokens immediately. Prompt/semantic caching returns a stored answer for repeated or near-duplicate prompts, skipping inference entirely — a direct latency and cost win. Model routing (cheap small model first, escalate to a larger model only when needed) cuts average cost without hurting quality on easy requests. The distractors miss: extra replicas don't speed up a GPU-bound call and raising the timeout makes latency worse (b); a blanket 24h CDN cache serves wrong/stale answers because prompts vary per user (c); and raising the output token limit increases tokens generated, raising latency and cost per call (d).
System Design/sd-architecture/ai-system-design
Streaming an LLM's tokens to the client over SSE reduces the perceived time-to-first-token, but it does not reduce the total cost of generating the response.#
Options
Show answer
True. Streaming changes delivery, not work. Sending tokens as they are produced lets the user see output begin in a few hundred milliseconds, dramatically improving perceived time-to-first-token. But the model still generates the same number of tokens through the same number of forward passes, so the compute — and therefore the cost — is unchanged. Cutting cost requires doing less inference.
Streaming changes delivery, not work. By sending tokens as they are produced, the user sees output begin in a few hundred milliseconds instead of waiting for the whole completion, which dramatically improves perceived latency (time-to-first-token). But the model still generates exactly the same number of tokens through the same number of forward passes, so the compute — and therefore the cost — is unchanged. To actually cut cost you need to do less inference: prompt/semantic caching, model routing to a cheaper model, or shorter outputs via lower max-token limits.
System Design/sd-architecture/ai-system-design
Why does capacity planning for an LLM inference service differ fundamentally from scaling a stateless CRUD service, and what is the main throughput lever on the serving tier?#
Options
Show answer
LLM serving is GPU-bound: capacity is driven by tokens/sec and concurrent requests rather than raw RPS, and continuous (dynamic) batching of in-flight requests on the inference server is the main throughput lever. A single generation holds the GPU for its whole token stream, so a request isn't a uniform unit of work like a CRUD call. Adding stateless replicas without GPUs does nothing for a GPU-bound workload.
LLM serving is GPU-bound, and a single generation holds the GPU for the duration of its token stream — so a request isn't a uniform unit of work like a CRUD call. Capacity is governed by tokens/sec and the number of concurrent requests the GPU memory can hold, not by request count alone. The dominant throughput lever is continuous/dynamic batching (e.g. vLLM-style): the server packs many in-flight requests through the GPU together and admits new ones as others finish, raising utilization far beyond serving one at a time. The distractors are wrong because adding stateless replicas without GPUs does nothing for a GPU-bound workload (b), the bottleneck is compute not the network/CDN (c), and weights stay resident in GPU memory rather than being reloaded from disk per request (d).
System Design/sd-architecture/ai-system-design
Adding a retrieval-augmented generation (RAG) layer to an LLM application eliminates hallucinations because the model always answers from the retrieved documents.#
Options
Show answer
False. RAG reduces hallucinations by grounding responses in retrieved source material, but it does not eliminate them. The model can still misread, mis-cite, or confabulate even when relevant context is present, and it hallucinates when retrieval itself fails on ambiguous queries or off-topic chunks. Mitigation needs retrieval-quality tuning, citation enforcement, and a confidence-based fallback to admitting it doesn't know.
RAG reduces hallucinations by grounding the model's response in retrieved source material, but it does not eliminate them. The model can still misread, mis-cite, or confabulate details even when relevant context is present. Additionally, hallucinations occur when retrieval fails — if the query is ambiguous, the top-k chunks are off-topic, or the answer is genuinely absent from the corpus, the model may fabricate. Mitigation requires retrieval quality tuning (reranking, chunk size, hybrid search), citation enforcement in the prompt, and confidence-based fallback to a 'I don't know' response.
System Design/sd-architecture/ai-system-design
You're designing a customer-facing chatbot backed by an LLM at scale. What are the key system-design concerns you'd address, beyond the model itself?#
Show answer
First, a latency budget: the inference call dominates, so I'd stream tokens over SSE to cut perceived time-to-first-token and set explicit p95 targets. Second, cost control: prompt/semantic caching to skip repeat inference, model routing (small model first, escalate only when needed), and output token limits to bound spend. Third, safety and abuse protection: input/output guardrails and content moderation, plus per-user rate limiting and quotas so one user can't run up the bill or degrade others. Fourth, production observability and ongoing evaluation: log prompts/responses/tokens/latency, trace requests, and run quality evals on sampled traffic to catch regressions. Fifth, resilience: the model API is a third-party dependency, so a circuit breaker that fails fast plus a degraded fallback (a cheaper/local model, a cached answer, or a graceful 'try again' message) keeps the product usable when the provider is down.
A production LLM chatbot is a distributed-systems problem layered on top of the model. The big five at the system altitude: (1) a latency budget — the inference call dominates p95, so stream tokens (SSE) to mask it; (2) cost control — prompt/semantic caching, model routing, and token limits, since per-request inference cost is the recurring bill; (3) safety + abuse — guardrails/moderation on input and output, and per-user rate limiting/quotas to bound spend and stop abuse; (4) observability + evaluation — log and trace prompts, tokens, latency, and run quality evals on sampled production traffic to detect drift; (5) resilience — the model API is an external dependency, so a circuit breaker and a degraded fallback (cheaper model, cached answer, graceful message) preserve availability when it fails. These are the levers an interviewer expects beyond 'call the model.'
System Design/sd-architecture/ai-system-design
In a RAG (Retrieval-Augmented Generation) system, what happens at query time and why is retrieval quality the critical bottleneck?#
Show answer
At query time the user's question is embedded into a vector, a similarity search retrieves the top-k most relevant document chunks from the vector store, and those chunks are prepended to the LLM's prompt as context before generation. Retrieval is the critical bottleneck because the LLM can only synthesise information that appears in its context window — it cannot reason about chunks it never received. A good retriever with a mediocre model often outperforms a great model with a poor retriever. Common failure modes: semantic mismatch between query and chunk embedding spaces, chunks too large (diluting signal) or too small (losing context), and missing reranking to promote the most relevant results within the top-k.
RAG decouples knowledge from model weights, making it possible to update a knowledge base without retraining. But 'garbage in, garbage out' applies at the retrieval step, not the generation step: if the right context isn't in the prompt, hallucination or a refusal is almost guaranteed. Reranking (a cross-encoder pass on the top-k candidates) is the most cost-effective improvement once baseline retrieval is working.
System Design/sd-architecture/ai-system-design
You are designing a production LLM inference serving layer that must handle variable traffic, control costs, and meet latency SLOs. Which architectural choices are sound?#
Options
Pick every one that applies.
Show answer
The sound choices are dynamic request batching so GPU compute is shared across in-flight requests, separating the prefill and decode phases onto different node pools because their resource profiles differ sharply, routing short low-complexity requests to a smaller cheaper model (model tiering), and using a KV-cache plus prompt prefix caching so shared prefixes aren't recomputed. Always running the largest model for every request blows cost and latency budgets without commensurate quality gain.
Efficient LLM serving requires treating the GPU as a scarce shared resource. Dynamic batching (a) packs multiple requests into one forward pass, amortising the fixed GPU overhead across them and dramatically improving throughput at similar latency. Disaggregating prefill and decode (b) — sometimes called prefill/decode disaggregation — is an emerging production pattern (used in systems like DistServe): prefill is compute-bound (processes the prompt tokens in one shot) while decode is memory-bandwidth-bound (generates one token at a time), so they have different optimal hardware and can be sized independently. Model tiering / cascading (c) routes easy requests cheaply; a small model handling 80% of traffic at a fraction of the cost is a major lever. KV-cache and prefix caching (e) avoid redundant computation for shared prompt prefixes — a critical optimisation when many requests share a long system prompt. Running the largest model for every request (d) ignores that cost scales roughly with model size while many requests are over-served by a smaller model; it blows cost and latency budgets without commensurate quality gain on simple tasks.
System Design/sd-architecture/ai-system-design
You're designing an LLM agent that can call real tools (send emails, query the database, hit internal APIs) on behalf of users. From a system-design standpoint, how do you stop a malicious input or a prompt-injection in retrieved content from making the agent take a damaging action?#
Show answer
Treat the model as untrusted and never give it direct authority to execute side effects. Put the privilege at the tool layer, not in the prompt: each tool runs with least-privilege, scoped credentials tied to the actual user's permissions, so even a hijacked agent can only do what that user could already do. Validate and constrain tool arguments before executing — schema-check them, allowlist destinations (e.g. only internal recipients), and bound parameters — rather than trusting whatever the model emitted. Keep a human-in-the-loop confirmation for high-blast-radius or irreversible actions (sending external email, deleting data, moving money). Defend specifically against prompt injection from retrieved/tool content by separating untrusted data from instructions and not letting fetched text silently escalate what the agent may do. Wrap it all in rate limits and quotas to bound damage and abuse, and log/trace every tool call so actions are auditable and reversible where possible. The principle: the model proposes, a guarded execution layer with real authorization disposes.
The core principle: the model proposes, a guarded execution layer disposes — never let the LLM hold direct execution authority. The system-design levers: (1) least-privilege, scoped credentials on each tool, tied to the user's real permissions, so a hijacked agent can't exceed what that user could do; (2) validate/constrain tool arguments before executing — schema checks, allowlisted destinations, bounded params — instead of trusting the model's output; (3) human-in-the-loop confirmation for irreversible / high-blast-radius actions (external email, deletes, payments); (4) treat retrieved/tool content as untrusted data, not instructions, to blunt prompt injection that tries to escalate privileges; (5) rate limits, quotas, and full audit logging/tracing of every tool call to bound and review damage. This is the authorization-and-validation boundary an interviewer expects around an agent, beyond 'give the model tools.'
System Design/sd-architecture/ai-system-design
Order the steps of a Retrieval-Augmented Generation (RAG) request, from user query to final response.#
Put these in order
Show answer
A RAG request flows from query to response in this order:
- Encode the user query into a vector embedding using an embedding model.
- Run an approximate nearest-neighbour search against the vector store to retrieve top-k chunks.
- Re-rank or filter the retrieved chunks for relevance (optional but common).
- Assemble a prompt that injects the retrieved context alongside the user query.
- Send the assembled prompt to the LLM and stream the generated response to the client.
RAG decouples knowledge from model weights: the embedding step translates the query into the same semantic space as the indexed documents; ANN retrieval identifies candidate chunks without scanning the entire corpus; re-ranking refines the noisy ANN results for precision; prompt assembly injects the grounding context so the LLM can cite specific facts rather than hallucinate; and generation is the final step, kept last so the model always sees the most relevant context. Skipping re-ranking is common at low scale but degrades answer quality for large corpora.
System Design/sd-architecture/ai-system-design
Design an LLM-powered customer-support assistant for a large SaaS product. Users ask questions in natural language; the assistant answers grounded in the company's own docs, help-centre articles, and the user's account context, and escalates to a human when unsure.#
Show answer
Requirements. This is grounded generation (RAG), not free-form chat: every answer must be backed by the company's own content, cited, and must never invent policy. Hard constraints: strict per-tenant isolation (no cross-account leakage), human escalation when the model isn't confident, and acceptable chat latency. LLM calls dominate cost and latency, so much of the design is about doing fewer/cheaper/cached calls.
Retrieval (RAG) pipeline. Offline, an indexing pipeline chunks the ~500K docs, embeds each chunk, and writes vectors + metadata (tenant, doc id, version, last-updated) into a vector store. It runs continuously so edited docs are re-embedded and the index stays fresh — that's how a policy reworded last week is reflected. At query time: embed the question → hybrid retrieval (vector similarity + keyword) for the top-k relevant chunks → assemble a prompt: system instructions + retrieved chunks (with their source ids) + the conversation → call the LLM, which answers from the provided context and returns citations.
Serving, cost & latency. The LLM is the bottleneck, so: cache responses (a semantic/embedding cache so near-duplicate questions reuse an answer); stream tokens so the user sees output immediately; tier models — easy/FAQ-matched queries get a small model or a direct retrieved-answer, only hard ones hit the large model; keep prompts tight (top-k, not the whole KB); and queue/batch under load to ride out the 100 QPS peak. These cut both spend and tail latency.
Grounding, hallucination & isolation. The system prompt instructs the model to answer only from the retrieved context and to say it doesn't know (and escalate) when the context doesn't cover the question — this is the main hallucination guard, reinforced by always returning citations the user can check. Tenant isolation is enforced at retrieval: the vector query is filtered by the requesting user's tenant_id (a metadata filter), so account-specific chunks for another tenant are never even candidates for the prompt. Enforcing it at retrieval (not by hoping the model behaves) is what makes leakage structurally impossible.
Failure handling & escalation. LLM calls get timeouts and retries; on provider outage we fail over to a fallback model or degrade gracefully to 'let me connect you to a human', never an indefinite hang. Low-confidence answers — weak retrieval scores, or the model signalling uncertainty — are escalated to a human queue with the conversation context attached, rather than guessing at policy.
Evaluation & scaling. Quality is tracked with an offline eval set (known Q→A pairs) run on each prompt/model change, LLM-as-judge plus human spot-checks on sampled live answers, and logging of every answer with its retrieved context and the user's thumbs feedback to find regressions and gaps. The serving tier is stateless and scales horizontally behind a load balancer; the vector store and indexing pipeline scale independently of it.
An LLM support assistant is the canonical RAG design, and the framing that separates a strong answer from 'just call the API' is treating it as grounded generation: an offline pipeline chunks and embeds the knowledge base into a vector store, and the request path retrieves the top-k relevant chunks and stuffs them into the prompt so the model answers from company content with citations — which (plus an explicit instruction to refuse/escalate when context is thin) is the real hallucination guard. The two constraints interviewers push on are cost/latency (LLM calls dominate, handled with semantic caching, streaming, model tiering, and tight prompts) and tenant isolation, which must be enforced at retrieval via a tenant metadata filter so another user's data is never even a candidate for the prompt — not left to the model's good behaviour. Rounding it out: provider-outage fallback, human escalation on low confidence (from retrieval scores), and continuous evaluation (offline eval sets, LLM-as-judge, feedback logging) so quality is measured rather than assumed.
Related interview questions
Job market
See system-design salaries and hiring demand from live job postings.
The other 17 questions
This page shows 10 and marks what you pick. That's as far as a page can go. A free account opens the other 17 and keeps every answer. What you miss comes back until it's right: after a day, then at longer gaps.
Free · the whole bank · 100 marked answers per 30 days · written feedback on the paid plan