Design an LLM Chat App (ChatGPT)

AI chat assistant inspired by ChatGPT and Claude: a stateless chat API that streams replies token by token, a GPU pool with continuous batching, prefix-aware routing to reuse KV caches, a context cache, per-plan token quotas metered from a queue, prompt moderation, and a smaller model for overflow. A teaching design.

Functional requirements

  • Users send a message and see the reply stream in as it is generated.
  • Each reply takes the earlier messages in the conversation into account.
  • Users can list and reopen past conversations.
  • Each plan has a message and token quota.
  • Prompts that break the usage policy are blocked.

Non-functional requirements

  • Time to first token: p99 < 1s.
  • Scale: 20M daily users, 4K requests/s at peak.
  • GPUs are the scarce, expensive resource: keep them busy, and degrade rather than fail when they're full.
  • Availability: 99.9%; conversations are never lost.
  • Usage is metered accurately enough to bill.

How the design evolves

Stage 1: One Server, One GPU, Wait for the Whole Reply

See why GPU inference can't live inside the web server.

What was missing: Nothing yet.

Why that's risky: A reply takes seconds to generate, and the user stares at a blank screen the whole time. The GPU serves one request at a time, so a few users fill it. Web traffic and GPU work can't be scaled separately.

What gets added: One server that saves the prompt, runs the model on its own GPU, and replies when the whole answer is generated.

Trade-offs: Simple, but expensive GPU time is wasted between requests and the web tier can't scale without buying GPUs.

Stage 2: Separate the Chat API from a Batched GPU Pool, and Stream

Scale cheap web servers and expensive GPUs separately, and show the reply as it is generated.

What was missing: The web server owned the GPU, and the user waited for the whole reply.

Why that's risky: Every request rebuilds the context from the database, and requests land on any GPU, so the model reprocesses the whole conversation each turn.

What gets added: A stateless chat API that saves the prompt and streams the reply token by token over server-sent events, a pool of GPU servers that batch many requests together (continuous batching), a conversations store partitioned by conversation id, and a history service.

Trade-offs: Streaming holds a connection open for the length of the reply. That's cheap on the chat API, and it makes the wait feel much shorter.

Stage 3: Context Cache and Prefix-Aware Routing

Stop paying to reprocess the same conversation every turn.

What was missing: Each turn reread the conversation from the database and landed on a random GPU, which recomputed the whole conversation's attention state.

Why that's risky: Nothing limits how much one user can send, nothing checks prompts, and usage isn't measured.

What gets added: A context cache holding the last few turns of active conversations, and an inference router that sends a conversation back to the GPU that already holds its prefix in its KV cache, or else to the least loaded one.

Trade-offs: Prefix routing can make one GPU busier than the rest. The router falls back to the least loaded GPU when the preferred one is full.

Stage 4: Quotas, Metering and Moderation

Make GPU time fair and paid for, and keep disallowed prompts off the GPUs.

What was missing: No limits per user, no usage numbers for billing, and no check on what was sent to the model.

Why that's risky: When every GPU is busy, requests queue at the router until they time out. There is no cheaper fallback, and one load balancer.

What gets added: A rate limiter enforcing each plan's messages per hour and token budget, a moderation classifier in front of the GPUs, and usage events that a metering worker adds up per user per day into a usage store that quotas read from.

Trade-offs: Metering is asynchronous, so a user can slightly overshoot their quota before it catches up.

Stage 5: Graceful Overload, Redundancy and Monitoring

Keep answering during a launch-day surge without buying GPUs for the peak.

What was missing: No fallback when the GPUs were full, one load balancer, and no view of time to first token.

Why that's risky: Remaining risk is GPU supply: the fleet can't grow in minutes, so a large surge is handled by degrading, not scaling.

What gets added: A pool running a smaller, faster model that takes simple prompts and overflow when the main pool is saturated, a rate limiter that sheds free-tier load first, a second load balancer, a replicated conversations store, more GPU servers, and monitoring of time to first token, tokens per second and GPU utilisation.

Trade-offs: Under load, some users get the smaller model's answers. Many products show this as "using a faster model right now".

PRISM
System Design Interview
Round 1 of 4 · Architecture Design · 60:00 remaining
PRISM logo
AI Interview
Interview Prep
Interview Challenges
Build & Stress Test NEW
System Architectures
Design & Fix NEW
Interactive Roadmap System Design Guides
Notifications
  • No new notifications
Feedback
Signed in
Send feedback
Phase
Build & Stress Test
Phase 01: Thinking in Systems
Upcoming

Components

User
CDN
Load Balancer
Server
Cache
Database
Blob Storage
Search Index
Queue
Worker
Rate Limiter
Service
API Gateway
Reverse Proxy
WebSocket Server
Third-party API

Inspector

Notes
Use clear names so your design intent is easy to understand.
Good
Name by business meaning
"Order API", "Restaurant Service"
Avoid
Generic names = zero signal
"Server 1", "API", "Queue"
A short description for each component makes feedback much better.
100%
Start by identifying:
  • Users & entry points
  • APIs & services
  • Databases & storage
  • Traffic flow & scale

Round 1 of 4 Architecture Design

Run a simulation to see results.

Time Remaining
60:00
System Design Interview

What are the core functional requirements?
What are the key non-functional constraints?

Questions

Start Evaluation to unlock questions.

EVALUATE MODE

Test yourself like it's the real thing.

A structured 4-module evaluation that mirrors how top companies assess system design candidates.

Architecture Design
Draw your system on the canvas. Define components, connections, and data flow.
FR & NFR Requirements
Answer functional and non-functional requirement questions about your design.
MCQ Round
Multiple choice questions testing your depth on the chosen system.
Tradeoff Analysis
Justify your design decisions and defend your architectural tradeoffs.
AI Report Generated
Choose a Problem
No problem selected
  • 30 min
  • 45 min
  • 60 min
Round 2 of 4
MCQ Round
Answer multiple-choice questions based on your design.

Exit Interview?

You're in the middle of an interview session. Leaving now will end your current attempt.

Your progress will be saved.

Open a saved design

Select a design to load into the canvas.

My Evaluations

Your past evaluation sessions

Here’s a simple request flow that follows the expected layer order.

External User
→
Edge CDN → API Gateway → Load Balancer
→
Compute App Servers / Services
→
DataAccess Cache
→
Storage Database / Search Index
→
Async Queue → Worker

Tip: keep arrows moving forward through layers (Edge → Compute → Storage). Avoid sending storage back to compute.

Evaluation Instructions

Read the rules carefully before starting. The test auto-submits on refresh.

Before you start

  • Build your architecture on the canvas. The timer starts when you click Start Evaluation.
  • Don't forget to answer Functional Requirement and Non Functional Requirements.
  • When satisfied with your design, click Next to lock it and view the questions.
  • Please answer final step questions to complete the evaluation.

Dos

  • Do read each question carefully before answering.
  • Do include required components to maximize component coverage.
  • Do save a copy of your design if you want to keep it before submission.

Don'ts

  • Don't refresh or close the tab during an active evaluation — this will auto-submit your answers.
  • Don't switch app modes or open another tab while the evaluation is running.
  • Don't attempt to edit the design after clicking Next; the workspace will be locked.

All the best!!

Confirm

Input

Notice

Evaluation Report

Evaluation Complete

Generating Your Report

Hang tight — our AI is evaluating your design…

Did you know?

Loading…

Share feedback

Tell us what worked well and what we can improve.

Let's personalize this

Answer a couple of quick questions so we can tailor your journey and missions.

Your welcome gift: of Full PRISM Access

You can change these answers from Mission Control until your missions are done.

Your personalized missions are ready

We tailored these first steps based on your answers.

    PRISM Welcome Gift

    This is a personal welcome gift from PRISM.

    Congratulations.

    You explored PRISM.

    You earned Apprentice.

    As a welcome gift, unlock Full PRISM Access for the configured trial duration.

    This starts Trial. Trial timer begins only after you activate this gift.

    Welcome to PRISM

    We've prepared a personalized Apprentice Journey based on your goals and experience.

    This journey introduces you to the capabilities of PRISM that are most relevant to you.

    Complete all 5 missions to earn your Apprentice title. 5 MISSIONS

    PRISM Surprise Offer

    Complete your Apprentice Journey to unlock a special gift from PRISM.

    • No payment required
    • No credit card required
    • Just complete the journey
    MISSION CONTROL
    0 / 8 missions complete
    NEXT UP Continue your missions
    View full roadmap →
    Mission Complete 0 / 8 Completed Next: Keep going
    SYSTEM BRIEF

    System Constraints

    What the system must do — every item is a user-facing behaviour your architecture must support.

      ↑ Engineering Constraints

      These are the failure modes you must design against — latency SLAs, durability targets, traffic ceilings.

        ⇆ Architecture Constraints

        Core Concepts to Master

        Your Journey
        PHASE – –
        0 / 0 0%
        0
        Mock Interview Checklist

        Pick a topic to start

        Explore concept overviews, real-system examples, key tradeoffs, and interview talking points for each roadmap section.

        Phase Mastered

        You've conquered this phase. These are the skills you now own:

          +500 XP

          Company Interview Paths

          Progress Summary