Design Twitter

Twitter/X architecture built progressively across 6 interview-scoped stages: tweet write path, follow graph, home-timeline fanout with hybrid celebrity handling, ranking/search (stretch goal), notifications/moderation, and monetization — kept deliberately lean (max 20 components) to match how a strong FAANG candidate would design and explain this system in 45 minutes.

Functional requirements

  • Users can create tweets, delete tweets, and view tweet details.
  • Users can follow or unfollow other users.
  • Users can view a home timeline of tweets from followed accounts.
  • Users can like, reply, repost/retweet, and quote-tweet posts.
  • Users can search tweets by keyword, hashtag, and user.
  • Users can receive notifications for engagement and relevant social events.
  • The platform should support trending topics and basic recommendation/ranking features.
  • The system should support ad or sponsored tweet insertion in timelines.
  • The platform should support moderation workflows for spam, abuse, and policy violations.

Non-functional requirements

  • Home timeline reads should remain low-latency under very high read-heavy traffic.
  • Tweet-create write path should stay responsive even when fanout, indexing, or notifications are backlogged.
  • The platform should degrade gracefully during downstream search, ranking, or notification failures.
  • The design should support celebrity users, hot tweets, and bursty global events without collapsing caches or fanout systems.
  • The system should provide strong observability for technical SLOs and product KPIs such as tweet impressions, timeline latency, and ranking quality.
  • The platform should remain available during regional incidents with explicit RPO/RTO and safe rollout controls.

How the design evolves

Stage 1: Tweet write path + object storage

Start with the core domain: create tweets, fetch tweet details, and model tweet lifecycle correctly.

What was missing: Nothing yet — this is the foundation. A naive first draft would put the User straight onto a single tweet server with no rate limiter and no object store, which falls over the moment media uploads or an abusive client shows up.

Why that's risky: A single un-sharded Tweet DB is a write bottleneck and a SPOF at this traffic level; acceptable for a Day-1 answer, not for the final one.

What gets added: A Load Balancer + a dedicated RateLimiter (not just an LB flag — interviewers expect to see it as its own decision point), a Tweet Service that owns the tweet CRUD path, a Tweet DB for durable storage, and a CDN + Blob Store pair so images/video never touch the app tier on a cache hit.

Trade-offs: No cache in front of the DB yet on purpose — stress testing this stage should show it as weak under a cache-outage scenario, which is exactly the lesson: you earn the cache in Stage 3, you don't start with one.

Stage 2: Follow graph + profile timeline

Add the social graph and the read models needed for user profile timelines and follow relationships.

What was missing: There was no notion of a social graph — Twitter is nothing without follows. Profile pages also had nowhere to live.

Why that's risky: Nothing computes a home timeline yet — today, 'following someone' has no visible effect on what a user sees. That gap is the entire motivation for Stage 3.

What gets added: A single User Service (profile + follow/unfollow, deliberately not split into 'ProfileAPI' and 'SocialAPI' — that's premature decomposition for this stage) backed by its own Follow DB, separate from Tweet DB so the graph can be scaled and partitioned independently of tweet storage.

Trade-offs: Follow DB is a graph-shaped read/write workload (fan-in/fan-out on celebrity accounts) that behaves very differently from Tweet DB's append-heavy workload — that's exactly why it's a separate store, not a table in the same DB.

Stage 3: Home timeline fanout + hot account strategy

Build the core read-heavy home timeline and handle the hardest product problem: celebrity fanout.

What was missing: The single hardest problem in this system: turning a tweet + a follow graph into a home timeline, at celebrity scale, without falling over.

Why that's risky: The event queue is now a single point of fanout delay under a write spike; if it backs up, timelines go stale for everyone — worth mentioning consumer-lag alerting even though it isn't drawn as a box.

What gets added: An Event Queue + Fanout Worker doing write-time fan-out into a Timeline Cache (Redis-style sorted set of tweet ids per follower) for normal accounts, a Tweet Cache in front of Tweet DB, and a Timeline Service that reads the cached timeline and, for celebrity/hot accounts, merges their tweets in at read time straight from Tweet Cache instead of fanning out to 50M followers on every tweet — this hybrid push/pull split lives entirely inside Timeline Service's own routing, not as a separate 'Hybrid' box, because in a real system it's a decision the timeline service makes per-author, not a standalone service.

Trade-offs: Fanout is asynchronous and eventually consistent — a new follower or a new tweet can take a moment to show up; that's the classic Twitter tradeoff and worth stating out loud in an interview.

Stage 4: Ranking, recommendations, search, and trends

Evolve from a recency feed into a ranked social platform with search and trending systems.

What was missing: A pure recency-ordered timeline and no way to find a tweet you didn't already have a link to — both are stretch-goal territory once the core read/write/fanout path is solid, which is why they land in Stage 4, not Stage 1.

Why that's risky: Search Index is a second source of truth for tweet text that must stay in sync with Tweet DB — an interview answer should mention 'near-real-time indexing pipeline' even though it's not drawn as a separate box here.

What gets added: A single Ranking Service (collapsed on purpose — a real candidate-retrieval + feature-store + scoring pipeline is 3-4 boxes in production, but for an interview answer one clearly-scoped 'scores and re-orders the candidate set, then caches the result' service is the right level of detail) that sits in front of Timeline Cache for cold/stale feeds, plus a Search Service + Search Index for keyword/hashtag lookup.

Trade-offs: Ranking adds latency and a new failure mode (a scoring bug or model rollout can silently make feeds worse, not just slower) — worth calling out as a monitoring gap even without drawing an observability stack.

Stage 5: Notifications, counters, conversations, and moderation

Add the major asynchronous product workloads that make the platform feel alive and safe.

What was missing: No way to tell a user something happened, and no safety net against spam/abuse — both are asynchronous side-effects of a tweet being created, not synchronous parts of the write path.

Why that's risky: Moderation is async and post-hoc: a spam tweet is briefly live before being scored — acceptable tradeoff to state explicitly (latency budget for posting must never wait on an abuse model).

What gets added: A Notification Service and a Moderation Worker, both added as additional independent consumer groups on the SAME tweet-event stream that already feeds Fanout Worker — no new queue, no new publish path on Tweet Service, because one event correctly has three independent async subscribers. Tweet counters and reply/conversation threading are deliberately NOT new boxes: counts live on Tweet DB/Tweet Cache, and a reply is just a tweet with a parent_id handled by the existing Tweet Service/Tweet DB — giving them their own services would be over-decomposition for an interview-scoped design.

Trade-offs: Notification delivery coalesces bursts ("and 499 others liked your tweet") rather than sending 500 pushes — a concrete, interview-worthy detail that shows you've thought about the failure mode of naive fan-out notifications.

Stage 6: Ads, analytics, experimentation, and global platform

Finish with the platform view: monetization, analytics, model training, multi-region control, and safe operations.

What was missing: Monetization — the business model that actually pays for everything above it.

Why that's risky: Ad selection quality/relevance is a whole separate ML system in production; here it's correctly scoped as 'out of bounds' for this design — said out loud, not hidden.

What gets added: One Ad Service that slots a sponsored tweet into the feed within a strict render-time budget; nothing else. This is intentionally the smallest possible Stage 6: multi-region active-active deployment, an analytics/experimentation data warehouse, ML training pipelines, an observability/incident-response stack, automated backups, and config/service-discovery infrastructure are all real production concerns a strong candidate should MENTION VERBALLY at this point in an interview — but drawing them as boxes would turn a 45-minute interview-level design into an infrastructure diagram. State them as 'here's what I'd add given more time', don't draw them.

Trade-offs: Ad Service has a hard timeout with a drop-the-slot fallback — monetization must never be allowed to slow down or destabilize the core product; a clean, quotable interview line.

Frequently asked questions

When do you use fanout-on-write vs fanout-on-read?

Use a hybrid approach. Precompute timelines for normal users where follower counts are manageable; switch celebrities and extreme hot accounts to fanout-on-read or partial materialization to avoid explosive write amplification.

How do you delete tweets without breaking timelines and search?

Use tombstones in the tweet store and publish delete events to all downstream consumers. Timeline caches, search indexes, conversation graphs, and analytics readers must interpret deletes idempotently.

How do you keep home timeline latency low when ranking is expensive?

Separate candidate generation from ranking. Use a candidate timeline store, cache hydrated tweets, maintain an online feature store, and degrade to recency or lightweight ranking when feature systems are slow.

How do you model likes, retweets, and impression counts safely at scale?

Write interaction events to a stream, aggregate asynchronously, and store eventually consistent counters separately from tweet objects. Keep UI tolerant to lagging counts and dedupe interaction events by user/tweet/action.

Why separate profile timelines from home timelines?

Profile timelines are author-centric and easy to partition by author/time, while home timelines are user-specific and require graph joins, fanout, and ranking. Keeping them separate avoids mixing two very different read patterns.

How do you handle trending topics without overloading the serving path?

Compute trends from the engagement stream asynchronously using windowed aggregations by region/topic. Serve trends from precomputed stores and let search or trends APIs degrade independently from core timeline reads.

How do you insert ads into the home timeline without hurting user experience too much?

Keep ad selection separate from organic feed computation. Inject sponsored candidates during ranking with pacing, campaign targeting, policy rules, and strict latency budgets; fall back gracefully if ad systems are unavailable.

How do you design the platform so ranking/search/moderation failures don’t take down tweeting?

Keep the tweet write path minimal and durable, then fan out events asynchronously. Downstream systems should consume independently with retries and DLQs; the platform should degrade by disabling enrichments rather than blocking core posting.

PRISM
System Design Interview
Round 1 of 4 · Architecture Design · 60:00 remaining
PRISM logo
AI Interview
Interview Prep
Interview Challenges
Design Your Own System NEW
System Architectures
Interactive Roadmap System Design Guides
Notifications
  • No new notifications
Feedback
Signed in
Phase
Design Your Own System
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.

Components Added
No components listed
Click "+ Add" to document components introduced in this stage.
Design Decisions

Click Simulate to run your design and see results here.

Internal notes — not shown to learners.

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
A R S
Used by engineers preparing for FAANG & top-tier companies
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.

You can change this anytime from your Profile.

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 8 missions to earn your Apprentice title. 8 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.

        Topic-Wise Progress
        Experience Points 0 XP
        Read subtopics & solve challenges to earn XP
        Theory Read +0 XP
        Solved +0 XP
        Streak Bonus +0 XP
        Theory Read 0%
        — Mastered — Solved
        Weekly Streak 0 day streak
        Mon
        Tue
        Wed
        Thu
        Fri
        Sat
        Sun
        Keep going — log in daily to build your streak!
        0 0%
        Skill Profile
        Recommended Next
        🎯 Your Focus

        You haven't explored enough yet.

        Focus on
        → Understanding System Design
        → Estimating Scale
        Next Action
        Continue → Next: –
        Mock Interview Checklist
        Architecture DNA
        Engineering Profile
        Phase Mastered

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

          +500 XP

          Engineering Profile

          Company Interview Paths

          Progress Summary