Twitter / X: High-Fanout Timelines, Snowflake IDs & Distributed Key-Value Stores
How Twitter/X routes half a billion daily tweets to 300M+ active users using hybrid push/pull fanout timelines, Snowflake 64-bit unique IDs, and Manhattan key-value clusters.
Twitter employs a hybrid timeline engine: regular users fan out writes into followers Redis timeline caches (push model), while celebrity accounts with millions of followers are merged dynamically on read (pull model) to prevent catastrophic fanout bottlenecks.
Hybrid Push vs Pull Fanout Topology
500M+ daily tweets and peak 150,000 tweets per second during world eventsCelebrity accounts with 50M+ followers cause millions of Redis list writes per second if purely push-based, resulting in massive queue latency.
Push writes for accounts with < 20,000 followers directly into follower timeline Redis lists. For accounts > 20,000 followers, store tweets in a user timeline and dynamically merge at read time.
Read latency slightly increases during feed fetch due to runtime merges, but eliminates write spikes and background worker queue starvation.
Always propose hybrid fanout in feed design rounds: write-fanout for normal users, read-merge for high-fanout power users.
Request/Response Lifecycle (Browser → Server → DB)
Trace the complete end-to-end journey of a single network packet from user click to database row mutation and DOM re-render.
IP Addressing (IPv4/IPv6, Public vs Private)
Explore numerical addressing schemes, subnetting (CIDR), NAT (Network Address Translation), and why private VPCs shield internal architectures.
HTTP/HTTPS Fundamentals
Understand the application protocol powering the World Wide Web, including plaintext HTTP vulnerabilities, TLS encapsulation, and status semantics.
HTTP Methods, Status Codes, & Headers
Master the RESTful grammar of the web: Idempotency semantics, safe vs unsafe methods, status classes (2xx, 3xx, 4xx, 5xx), and caching/security headers.
TCP vs UDP Tradeoffs
Compare reliable byte streams against lightweight datagrams: flow control, congestion avoidance, head-of-line blocking, and when to pick UDP for real-time scale.
TCP Three-Way Handshake & Connection Lifecycle
Deep dive into SYN, SYN-ACK, ACK, sequence number synchronization, state machines (ESTABLISHED, TIME_WAIT), and connection termination (FIN/RST).
TLS/SSL Handshake & Encryption Basics
Understand asymmetric vs symmetric cryptography, Diffie-Hellman Ephemeral key exchange, X.509 Certificate Authorities, and TLS 1.2 vs TLS 1.3 1-RTT/0-RTT speedups.
OSI vs TCP/IP Model Overview
Understand abstraction layers in distributed networking: Layer 4 (Transport/TCP) vs Layer 7 (Application/HTTP), encapsulation, and debugging network boundaries.
Sockets & Ports (Network Programming Basics)
Explore kernel network primitives: File descriptors, socket bindings, ephemeral port allocations, non-blocking I/O, and the C10K/C1000K concurrent connection problem.
Raffi Krikorian, Twitter Engineering • 2022
Ready to Practice Twitter / X-Style Systems?
Start with foundational networking, compute, and storage, and build up to complex distributed consensus.