Design Social Media

Social network inspired by Facebook's published designs: a TAO-style object and association graph in sharded MySQL behind tiered caches, privacy checks on every read, feeds assembled at read time from in-memory activity leaves and ranked, notifications, social search and integrity classifiers. A teaching design.

Functional requirements

  • Create, read, like, and comment on posts (text, images, short videos).
  • Follow/unfollow users; timelines show posts from follows and recommendations.
  • Media upload with background processing (transcode/thumbnail) and CDN delivery.
  • Real-time notifications for likes, comments, follows, and mentions.
  • Search users, hashtags, and posts; trending and explore discovery pages.
  • Content moderation (automated + manual review) for policy violations.
  • Profile pages with stats; edit profile, avatars, and bios.
  • Session management and secure authentication across devices.

Non-functional requirements

  • Availability: 99.95%+; single instance or AZ failure must not disrupt timelines.
  • Performance: p99 timeline read < 150 ms cache-warm; post publish visible to followers < 5 s p95.
  • Scalability: independently scale feed, social graph, and media; support millions of DAU.
  • Durability: posts and interactions persisted with transactional guarantees and backups.
  • Consistency: strong for auth/profile writes and post creation; eventual for feed fan-out and search indexing (< 30 s).
  • Security: TLS 1.2+; signed media URLs; principle of least privilege; secrets in KMS.
  • Resilience: timeouts/circuit breakers; retries with backoff; DLQs for poison messages.
  • Observability: traces/logs/metrics for API, feed fan-out latency, queue depth, and error rates.
  • Privacy: GDPR/CCPA compliance; PII encryption at rest (AES-256).

How the design evolves

Stage 1: Single Web Server and Database

See why rendering every page with SQL against one database collapses.

What was missing: Nothing yet.

Why that's risky: A single page needs dozens of queries (the person, their friends, each post, its likes), and 200K page views per second crush one database.

What gets added: One server rendering profiles, posts and the feed with SQL against one database.

Trade-offs: Simple, but the social graph is read far more than it's written.

Stage 2: Objects and Associations Behind a Graph Cache

Model the social graph explicitly and serve almost all reads from memory.

What was missing: Pages ran many SQL queries each, all on one database.

Why that's risky: Any server that fetches an object could show it to anyone: audiences and blocks aren't checked consistently.

What gets added: A TAO-style data model of objects (people, posts, comments) and associations (friend, authored, liked) in sharded MySQL, behind a read-through graph cache with follower tiers for reads and leader tiers that write through and keep caches consistent; photos in object storage behind a CDN.

Trade-offs: Caches are eventually consistent across regions; a person always reads their own writes.

Stage 3: Privacy Checks on Every Read

Make sure nobody ever sees something its audience excludes.

What was missing: Audience rules were checked inconsistently, page by page.

Why that's risky: The feed is still assembled by querying every friend's posts.

What gets added: A privacy checker that every object passes through before it's shown, applying its audience (public, friends, custom lists) and the viewer's blocks.

Trade-offs: Every object costs a privacy check; checks read audience lists from the graph cache to stay fast.

Stage 4: Feed from In-Memory Activity Leaves, Ranked at Read Time

Build each feed fresh, in under a second, from recent activity of everyone followed.

What was missing: Feeds queried every friend's posts from the graph.

Why that's risky: People aren't notified of comments and likes, and there's no search.

What gets added: An activity stream and leaf indexers that keep each person's recent actions in memory on leaf servers, and a feed aggregator that queries the leaves for everyone the viewer follows, ranks the candidates and checks their privacy at read time.

Trade-offs: Pull at read time does more work per feed view than precomputed feeds, but handles accounts with huge followings and privacy changes instantly.

Stage 5: Notifications and Social Search

Tell people about interactions and let them find people and posts.

What was missing: No notifications and no search.

Why that's risky: Harmful content and fake accounts aren't caught, and nothing limits posting rates.

What gets added: A notification worker for comments, likes, tags and friend requests, and a social search index (fed from the activity stream) whose results favour the searcher's connections.

Trade-offs: Search results lag new posts by seconds.

Stage 6: Integrity, Limits and Monitoring

Catch harmful content, slow abuse, and watch the platform.

What was missing: No integrity checks, no abuse limits, no monitoring.

Why that's risky: Remaining risk is regional: graph caches and shards must fail over between data centres.

What gets added: An integrity classifier on the activity stream that removes clear violations and queues borderline ones for human review, rate limits on posting and friending, and monitoring of page and feed latency and cache hit rates.

Trade-offs: Classification happens just after posting, so a violation can be visible for seconds.

Frequently asked questions

How do you keep post creation idempotent and fast under retries?

Require a client-supplied idempotency key for post creation. Persist the key with the final post ID and return the stored result on retries. Use a queue/outbox to publish to feed fan-out and notifications asynchronously.

Write fan-out vs. read fan-out — which do you choose and why?

Write fan-out materializes follower timelines asynchronously for fast reads at scale; read fan-out composes on read, reducing write load but increasing read latency. Many systems mix both: materialize partial feeds for hot users and compose on read for long tails.

How do you implement search across users, hashtags, and posts?

Index user handles, names, hashtag tokens, and post text into a Search Index asynchronously via a queue. Query the index for autocomplete, trending, and discovery; do not scan the OLTP databases.

How do you prevent abuse and enforce rate limits?

Apply token bucket or sliding window rate limits at the edge per IP and per user. Backed by a fast cache store. Monitor for anomalies and add circuit breakers on hot endpoints.

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