Design Snapchat

Ephemeral messaging and stories platform inspired by Snapchat: media in object storage behind a CDN, expiry that deletes content once opened, realtime chat with push for offline users, friend-graph privacy checks and 24-hour stories. A teaching design, not Snap's internal architecture.

Functional requirements

  • Users can send photo/video snaps and chat messages to friends.
  • Users can open snaps, and the system tracks opened, expired, and screenshot-related metadata.
  • Users can configure a snap as view-once, replay-limited, or saved-in-chat depending on product rules.
  • Users can post stories that expire automatically after a fixed window.
  • Users can save snaps to personal Memories without breaking default ephemeral delivery semantics.
  • Users can receive real-time chat updates and offline push notifications.
  • The system should support Snapchat-specific engagement features like streaks.
  • The platform should support Discover-style publisher content and cached feed delivery.
  • The system should support media processing, safety checks, and access-controlled media delivery.
  • The platform should support friend graph semantics including privacy lists, blocking, and audience restrictions.
  • Users can send, accept, reject, or block friend requests.
  • Story creators can inspect story viewers, and the system tracks unique vs repeat story views.
  • The system should support AR lenses/filter metadata and device-targeted lens delivery.
  • The platform should support analytics and ranking signals for discovery, creator insights, and product tuning.

Non-functional requirements

  • The system should support millions of daily active users with bursty write traffic during peak social events.
  • Real-time message delivery should target sub-300ms end-to-end latency for online recipients under normal load.
  • The system should provide strong privacy guarantees around ephemeral content expiry and controlled access.
  • The architecture should isolate chat, stories, discover, and moderation workloads so one domain does not collapse the others.
  • The platform should remain available during regional failures with documented RPO/RTO goals.
  • The system should provide auditability, abuse controls, and safe operational rollout/rollback behavior.
  • The platform should scale reads and media delivery independently from write-heavy messaging paths.
  • The system should provide observability for both technical SLOs and product KPIs such as opens, streak retention, and story completion rates.
  • The design should support eventual partitioning by user, conversation, publisher, or geography as single-cluster limits are reached.

How the design evolves

Stage 1: Single Server, Media in the Database

See why storing media in database rows and deleting nothing fails both scale and the ephemeral promise.

What was missing: Nothing yet: one server receives, stores and serves every snap.

Why that's risky: Megabytes of media per row make the database the bottleneck at once, and nothing deletes opened or expired snaps, so 'ephemeral' is only a promise.

What gets added: An app server and a database that keeps each snap's photo or video in the same row as its details.

Trade-offs: Easy to build, but it mixes small hot records with huge cold files.

Stage 2: Media out of the Database, Expiry That Really Deletes

Keep media in object storage behind a CDN, and make expiry an actual deletion, not a flag.

What was missing: Media lived in database rows and nothing ever deleted opened or expired snaps.

Why that's risky: Chats and new-snap alerts arrive only when the app polls, and offline users never hear about them.

What gets added: The app uploads media straight to object storage with a signed URL; recipients fetch it through a CDN with short-lived signed URLs. The message store keeps only small records with a TTL, and expiry jobs delete both the file and the record once every recipient has opened it or it times out.

Trade-offs: Deleting on open means a missed delete leaves content around; a TTL on the record and lifecycle rules on storage act as a second safety net.

Stage 3: Realtime Chat and Push

Deliver chats and snap alerts instantly to online users and by push notification to offline ones.

What was missing: No persistent connection, so chats and alerts depended on polling, and offline users got nothing.

Why that's risky: Nothing checks friendships or blocks before delivering, so anyone could message anyone.

What gets added: Chat gateways holding persistent connections, a chat service that stores messages in order per conversation, a per-user delivery channel to the gateway holding the recipient's connection, and a push worker that notifies offline users through APNs and FCM.

Trade-offs: Delivery is at-least-once: clients deduplicate by message id rather than the server trying to deliver exactly once.

Stage 4: Friend Graph and Privacy

Only friends can reach each other, and blocks take effect everywhere.

What was missing: No friend relationships or blocks: delivery didn't check who was allowed to reach whom.

Why that's risky: There is no way yet to share a story with all friends at once.

What gets added: A friend graph service for requests, accepting, removing and blocking; a friend graph database; and a cache of friend and block lists that every snap and chat checks before delivery.

Trade-offs: The friend cache can be a moment stale; blocking also invalidates it immediately so a block is never delayed.

Stage 5: Stories

Post once to all friends for 24 hours, and show each user a tray of friends' active stories.

What was missing: Content could only go to chosen recipients one at a time; there was no broadcast to all friends.

Why that's risky: Uploads aren't checked for abuse before delivery, and there is no visibility into engagement or the system's health.

What gets added: A story service that posts a story once with a 24-hour TTL and records viewers, plus a story tray cache per user built from friends' active stories.

Trade-offs: Trays are built when friends post (fan-out on write) because opening the app and reading the tray is far more frequent than posting.

Stage 6: Media Safety, Analytics and Observability

Check uploads before delivery, collect engagement without slowing the app, and watch the system's health.

What was missing: Uploads went out unchecked and unprocessed, and nothing measured engagement or system health.

Why that's risky: Remaining risk is regional: a full region outage needs failover to another region's copies of the data.

What gets added: An upload queue and media processing workers (transcoding, thumbnails, safety classifiers) that run before recipients can open content; an engagement stream feeding a warehouse in micro-batches for streaks, ranking and creator insights; and monitoring.

Trade-offs: Safety checks add a short delay before a recipient can open a video, in exchange for blocking abuse before it spreads.

Frequently asked questions

How do you guarantee media expires?

Use storage lifecycle policies + periodic sweepers; enforce access tokens with expiry; delete metadata+blobs on schedule.

How do you model view-once, replay-once, and saved-in-chat behavior without hardcoding rules in clients?

Keep a server-side snap lifecycle policy that evaluates message type, chat settings, open state, replay counters, and save permissions. Clients render based on policy decisions, but the source of truth stays on the server.

Why should Memories be stored separately from normal snap blobs?

Memories have different retention, backup, access, and privacy guarantees than ephemeral delivery blobs. Separating them prevents accidental deletion coupling and makes encryption, restore, and legal retention behavior easier to reason about.

How do you represent friend requests, blocks, and custom audiences cleanly?

Model them as different edge types or stateful relationships in the social graph. This lets the same graph support request flows, access control for private stories, and delivery eligibility checks without duplicating logic across services.

How do you track story viewers when users may watch the same story multiple times?

Keep both a unique-view model and a repeat-view event stream. Use the viewer store to track first-seen order and creator-visible viewer lists, while analytics pipelines separately aggregate repeat views, completion rate, and dwell time.

Why separate chat delivery from stories instead of one unified feed service?

Chat needs low-latency person-to-person delivery and receipt tracking, while stories are high-read fanout content with different caching, ranking, and expiry patterns. Splitting them keeps data models and scaling strategies clean.

How do you avoid duplicate notifications or duplicate chat delivery on reconnect?

Use conversation-scoped sequence numbers, idempotent client acknowledgements, and durable inbox state so reconnecting clients can request only the delta since their last confirmed cursor.

How would you model streaks without making every message write expensive?

Keep chat delivery separate from streak accounting. Emit lightweight message-open or send events, update streak counters asynchronously in a fast counter store, and periodically reconcile counters into durable storage.

Why is Discover modeled separately from stories?

Discover behaves more like a publisher feed with ranking, editorial controls, regional availability, and content shelves. Stories are mostly friend-graph fanout with expiry. They share some infrastructure, but not the same product logic.

Why model the friend graph separately instead of storing it in the chat database?

Friendship edges, blocks, best-friend signals, private story audiences, and recommendation inputs evolve independently from chat delivery. A dedicated friend graph service/store keeps access checks, social features, and privacy logic reusable across chat, stories, and Discover.

How do you keep story fanout manageable for celebrities with millions of followers?

Use hybrid fanout. Precompute trays for normal users, but for high-fanout publishers use fanout-on-read or partial materialization with cached shelf fragments. Track publisher fanout cost and dynamically choose the strategy.

How do you safely run experiments or feature rollouts on a global social app?

Use feature flags with cohort targeting, region-scoped rollouts, kill switches, and observability tied to both technical SLOs and product metrics. New lenses, ranking models, or UI changes should be gradual and reversible.

How do you design a global event backbone without making every consumer depend on one giant topic?

Partition the event backbone by domain and key: chat by conversation, stories by publisher/user, engagement by content/user, and abuse signals by account/device. This keeps replay targeted, consumers isolated, and hot partitions manageable.

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
System Design Guides Interview Prep Guide
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.

    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
    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