Design an AI Image Generator (Midjourney)

AI image generation inspired by Midjourney and DALL·E: prompts accepted as queued jobs, a fleet of GPU workers running diffusion, a fast lane for paid plans and a relaxed lane for free ones, live previews from a progress cache, images in object storage behind a CDN, a cached gallery, prompt moderation and image safety checks. A teaching design.

Functional requirements

  • Users type a prompt and get generated images.
  • Users see the image forming while it generates.
  • Paid plans are served before free plans.
  • Users can browse their gallery and a public showcase.
  • Disallowed prompts and unsafe images are blocked.

Non-functional requirements

  • Prompt submission and status: p99 < 300ms.
  • Fast-lane images finish in under a minute at peak.
  • Scale: 10M daily users, 3K requests/s at peak, most of it viewing.
  • Generated images are never lost once shown.
  • Availability: 99.9%.

How the design evolves

Stage 1: Generate Inside the Request

See why holding a request open for a 30-second GPU job doesn't scale.

What was missing: Nothing yet.

Why that's risky: An image takes tens of seconds, so connections time out and the GPU serves one prompt at a time. Image bytes bloat the database, and every page view pulls them through the server.

What gets added: One server with a GPU that generates each image while the request waits, then stores the image bytes in the database.

Trade-offs: Simple, but GPU and web work can't be scaled separately.

Stage 2: A Job Queue and GPU Workers

Accept prompts instantly, and keep a fleet of GPUs busy from a queue.

What was missing: Generation ran inside the request and images lived in the database.

Why that's risky: Paying users wait behind free users in one line, users see nothing until the image is done, and every poll reads the database.

What gets added: A job API that checks credits, saves the job as queued and returns at once; GPU workers that take jobs from a queue and upload finished images to object storage; and a status service the client polls.

Trade-offs: The client polls instead of waiting, which is the right shape for work that takes seconds to minutes.

Stage 3: Priority Lanes and Live Previews

Serve paying users first, and show the image forming.

What was missing: One line for everyone, and nothing to see until the image was done.

Why that's risky: Finished images are served from object storage on every view, and galleries query the database directly.

What gets added: Two queues: a fast lane for paid plans that GPUs always serve first, and a relaxed lane served whenever a GPU is free. Workers write a low-resolution preview every few denoising steps to a progress cache, which status polls read instead of the database.

Trade-offs: Relaxed jobs can wait minutes at peak. That is the product: speed is what users pay for.

Stage 4: Images on a CDN and a Cached Gallery

Serve the much larger viewing traffic cheaply.

What was missing: Every image view hit object storage, and galleries queried the database.

Why that's risky: Any prompt reaches the GPUs, including disallowed ones, one load balancer, and nothing caps a user's request rate.

What gets added: A CDN in front of image storage, thumbnails for gallery grids, and a gallery service with a cache of recent pages and the public showcase feed.

Trade-offs: Images are immutable once generated, so the CDN can cache them indefinitely.

Stage 5: Moderation, Limits, Redundancy and Monitoring

Keep disallowed content off the GPUs and out of galleries, and see queues before users complain.

What was missing: Disallowed prompts used GPU time, nothing checked finished images, and no per-user limits.

Why that's risky: Remaining risk is GPU supply: a viral moment fills the relaxed lane for a while, by design.

What gets added: Prompt moderation before a job is queued, a safety classifier on every finished image, a rate limiter on requests and concurrent jobs per plan, a second load balancer, a replicated jobs database, more GPU workers, and monitoring of queue wait per lane and seconds per image.

Trade-offs: Moderation blocks a few harmless prompts. Appeals and tuning reduce that over time.

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