Chaturmind
LearnDSASystem DesignDevOpsEngineering GrowthBlog
Start learning
Chaturmind

Structured learning paths for engineers who want to go deep. Written by practitioners.

Learn

  • Java
  • DSA
  • System Design
  • Spring Boot
  • AI / ML
  • DevOps
  • Engineering Growth

Company

  • Blog
  • Contact

Legal

  • Privacy Policy
  • Terms of Service

© 2026 Chaturmind. All rights reserved.

Built for engineers who want to go deep.


← System Design Interview Playbook

Interview Framework

  • The 6-Step Design Framework
  • HLD Fundamentals Refresher
  • Requirement Gathering Practice
  • Domain Decomposition
  • API Contract Design
  • Data Ownership Model
  • Failure Scenario Walkthroughs
  • Architecture Diagramming
  • Back-of-Envelope Estimation

10 Case Studies

  • Design a URL Shortener
  • Design Twitter / X
  • Design WhatsApp
  • Design Netflix
  • Design a Rate Limiter
  • Design a Search Autocomplete
  • Design a Distributed Cache
  • Design a Notification Service
  • Design Uber / Ride Sharing
  • Design a Distributed File Storage System
  • Design a Distributed Task Scheduler
  • Design a Message Queue System
  • Design an Authentication System at Scale
  • Design a Distributed Logging & Metrics Pipeline
  • Design a Food Delivery Platform
  • Design a Real-Time Analytics Dashboard
  • Design a Monitoring & Alerting System
  • Design Container Orchestration Basics
  • Design a CI/CD Pipeline System
  • Design Service Mesh Basics
  • Design a Centralized Configuration & Secrets System
  • Design a Batch Processing System
  • Design a Data Warehouse / Analytics Storage Layer
  • Design Global Content Delivery
  • Case studies

    🏗️Design a URL Shortener
  • 🏗️Design a Rate Limiter
  • 🏗️Design Twitter / X
  • 🏗️Design WhatsApp
  • 🏗️Design Netflix
  • 🏗️Design a Distributed Cache
  • 🏗️Design a Notification Service
  • 🏗️Design a Search Autocomplete System
  • 🏗️Design Uber / Ride Sharing
  • 🏗️Design a Web Crawler
  • 🏗️Design a Payment System
  • 🏗️Design a Distributed Lock Service
  • 🏗️Design a Video Streaming Platform
  • 🏗️Design a Search Engine
  • 🏗️Design E-Commerce Checkout & Inventory at Scale
Chaturmind
← System Design Interview Playbook

Interview Framework

  • The 6-Step Design Framework
  • HLD Fundamentals Refresher
  • Requirement Gathering Practice
  • Domain Decomposition
  • API Contract Design
  • Data Ownership Model
  • Failure Scenario Walkthroughs
  • Architecture Diagramming
  • Back-of-Envelope Estimation

10 Case Studies

  • Design a URL Shortener
  • Design Twitter / X
  • Design WhatsApp
  • Design Netflix
  • Design a Rate Limiter
  • Design a Search Autocomplete
  • Design a Distributed Cache
  • Design a Notification Service
  • Design Uber / Ride Sharing
  • Design a Distributed File Storage System
  • Design a Distributed Task Scheduler
  • Design a Message Queue System
  • Design an Authentication System at Scale
  • Design a Distributed Logging & Metrics Pipeline
  • Design a Food Delivery Platform
  • Design a Real-Time Analytics Dashboard
  • Design a Monitoring & Alerting System
  • Design Container Orchestration Basics
  • Design a CI/CD Pipeline System
  • Design Service Mesh Basics
  • Design a Centralized Configuration & Secrets System
  • Design a Batch Processing System
  • Design a Data Warehouse / Analytics Storage Layer
  • Design Global Content Delivery
  • Case studies

    🏗️Design a URL Shortener
  • 🏗️Design a Rate Limiter
  • 🏗️Design Twitter / X
  • 🏗️Design WhatsApp
  • 🏗️Design Netflix
  • 🏗️Design a Distributed Cache
  • 🏗️Design a Notification Service
  • 🏗️Design a Search Autocomplete System
  • 🏗️Design Uber / Ride Sharing
  • 🏗️Design a Web Crawler
  • 🏗️Design a Payment System
  • 🏗️Design a Distributed Lock Service
  • 🏗️Design a Video Streaming Platform
  • 🏗️Design a Search Engine
  • 🏗️Design E-Commerce Checkout & Inventory at Scale
HomeLearnSystem DesignSystem Design Interview Playbook10 Case Studies
✓ FreeAdvanced· 25 min read

Design Twitter / X

Fan-out on write vs read, timeline generation, tweet storage — Twitter's core feed system.

Published September 21, 2026


Design: Twitter/X

Requirements

Functional: Post tweets, Follow users, View home timeline, Like/Retweet Scale: 300M DAU, 500M tweets/day, 100B timeline reads/day

The Core Problem: Home Timeline

Generating a user's timeline = aggregating tweets from everyone they follow. If a user follows 1000 people, a naive query SELECT * FROM tweets WHERE user_id IN (followees) ORDER BY created_at is extremely expensive at scale.

Two Approaches

Fan-out on Write (Push model)

When User A tweets, push the tweet ID to every follower's timeline cache.

Tweet posted by User A
  → Message queue
  → Fan-out worker reads follower list (500 followers)
  → Writes tweet_id to each follower's timeline in Redis

Timeline read:
  → Read from Redis cache (O(1) per user)
  → Extremely fast!

✅ Fast reads ❌ Write amplification for celebrities (Katy Perry has 150M followers → 150M Redis writes per tweet)

Fan-out on Read (Pull model)

When user views timeline, query tweets from all followees.

Timeline read for User B (follows 1000 people):
  → Fetch last 20 tweet IDs from each of 1000 followees
  → Merge-sort 20,000 tweets → top 20
  → Cache result per user

✅ No write amplification ❌ Very slow for users following many people; complex to cache

Hybrid (Twitter's actual approach):

  • Regular users (< ~10K followers): fan-out on write
  • Celebrities (> ~10K followers): fan-out on read, merged at query time

Data Model

-- Tweets: Cassandra (time-series, high write)
tweets: tweet_id (Snowflake), user_id, text, media_urls, created_at

-- Follow graph: Graph DB or Cassandra
follows: follower_id, followee_id, followed_at

-- Timeline cache: Redis sorted set per user
-- key = "timeline:{userId}"
-- score = tweet timestamp, value = tweet_id

Architecture

API Gateway → Load Balancer
  ↓
[Tweet Service] → Cassandra (tweets)
  ↓
[Fanout Service] ← message queue
  ↓
[Redis Timeline Cache]  ← ZADD timeline:{userId} score=ts value=tweetId
  ↓
[Timeline Service] → hydrate tweet IDs → return tweets

Interview Tips

  1. The fan-out problem is the crux — explain both approaches and the hybrid.
  2. Use Snowflake IDs (time-sortable) so tweets are naturally ordered by ID.
  3. Celebrity handling is the key insight that separates strong candidates.

Previous

Design a URL Shortener

Next

Design WhatsApp

AI Tutor

Lesson: Design Twitter / X

Quick actions

AI responses can be inaccurate. Verify critical information.