Design Image Hosting

Image hosting service inspired by Imgur and Cloudinary: uploads go to object storage with a small metadata row, a CDN serves viewers from the edge, and thumbnails are made in the background.

Functional requirements

  • Upload an image (up to 10 MB) and get back a shareable link; the file is stored in object storage and a small metadata row is saved
  • View an image by its link, served from the CDN so popular images load quickly everywhere
  • Generate smaller thumbnails of every upload in the background
  • Keep every uploaded image until its owner deletes it, and remove it from storage and the CDN when they do
  • Reject files that are not images, and files that are too large
  • Limit uploads per user or IP so one client cannot fill the storage

Non-functional requirements

  • View latency < 100ms p99 for popular images via the CDN and hot image cache
  • Upload accepted < 500ms p99 for the request, with the file going straight to storage
  • Thumbnails are ready within 30 seconds of upload
  • Handle 10K image views per second at peak and 200 uploads per second
  • 99.999% durability: an uploaded image is never lost (replicated object storage)
  • Scale to 100M images stored; storage cost grows linearly and cold images move to cheaper tiers
  • 99.99% availability for viewing

How the design evolves

Stage 1: Single Server, Images in the Database

See why storing image bytes in database rows and serving them from one server breaks down.

What was missing: Nothing is separated: one server handles uploads and views, and image bytes sit inside database rows.

Why that's risky: Reading a 3 MB image streams it through the database and evicts hot rows from its buffer cache; at 10K views/s the database saturates first (125% load).

What gets added: A single server and a database where each image is one row holding megabytes of bytes.

Trade-offs: Simplest to build, with transactional uploads, but databases are tuned for small rows, not blobs.

Stage 2: Object Storage for Images

Keep image bytes in object storage and only small records in the database.

What was missing: Image bytes live in database rows and one process does everything.

Why that's risky: Every view still costs a metadata lookup plus a storage fetch, and a viral image repeats that same fetch thousands of times a second.

What gets added: Image bytes move to object storage and the database keeps only a small row per image (owner, size, object key). The upload service hands the client a short-lived signed link, so bytes go straight to storage and never pass through our servers.

Trade-offs: Two stores can disagree: if the bytes upload but the row insert fails you leave an orphan object, so write the object first and sweep unreferenced objects later.

Stage 3: CDN and Hot Image Cache

Serve popular images from the edge and from memory so viral images never reach storage.

What was missing: Popular images are fetched from storage again on every single view.

Why that's risky: A cold cache or a CDN outage sends full traffic to the view service at once, and a deleted image keeps serving from the edge until its copy expires.

What gets added: A CDN serves images from edge locations near viewers, and a hot-image cache sits behind the view service for what the CDN misses.

Trade-offs: An image never changes after upload, so its URL can be cached at the edge for a year; the cost is that a delete needs an explicit purge, or the image lingers until the copy expires.

Stage 4: Upload Limits, Thumbnails and Monitoring

Protect uploads from abuse and make thumbnails in the background.

What was missing: Uploads are unprotected, thumbnails are not made, and no one can see problems.

Why that's risky: If thumbnails were made inside the upload request, a burst of 10 MB photos would block uploads for everyone.

What gets added: A rate limiter in front of uploads, a queue feeding thumbnail workers that write small and medium versions, and a monitoring service.

Trade-offs: Upload returns as soon as the bytes are stored, so a thumbnail can appear a few seconds late; clients show the original until it is ready.

PRISM
System Design Interview
Round 1 of 4 · Architecture Design · 60:00 remaining
PRISM logo PRISM logo
Problems
AI Interview
Interview Challenges
Build & Stress Test NEW
System Architectures
Design & Fix NEW
Interactive Roadmap
Problems
Today's mission
Notifications
    Theme
    Pricing Community NEW Send feedback Report a problem NEW
    Sign in
    Theme
    Community NEW Send feedback Report a problem NEW
    All problems
    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.

    Test yourself like it's the real thing.

    Interview prep guide
    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 interviews left 0left
    This week 0 / 0
    Used today 0 / 0

    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
    Report a problem

    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

    Your Pro access starts as soon as you press Start my journey.

    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