Twitter System Design

Quick Reference: Instagram | Step 7: Pub/Sub


Quick Reference

Scale: 400M+ tweets/day, 200M+ users

Key Components: Timeline generation, real-time feeds, fan-out, search

Challenges: Real-time timeline generation, write-heavy workload


Clear Definition

Twitter is a real-time social media platform requiring fast timeline generation, real-time updates, and handling massive write and read volumes.

šŸ’” Key Insight: Twitter uses fan-out (push) for popular users, pull for others. Hybrid approach balances performance and complexity.


Core Concepts

Timeline Generation

  • Fan-out (Push): Pre-compute timelines for followers
  • Pull: Generate on-demand for less active users
  • Hybrid: Combine both approaches

Key Design Decisions

  • Sharding: Shard by user_id
  • Caching: Cache timelines
  • Message Queue: Handle tweet distribution
  • Search: Real-time search index

Quick Reference Summary

Twitter: Real-time social platform with massive scale.

Key Components: Timeline generation, fan-out, search.

Key Design: Hybrid push/pull, sharding, caching.


Previous Topic: YouTube ←

Next Topic: WhatsApp →

Back to: Step 12 Overview | Main Index