X's system design

0/3
☰
X / Twitter · system design

X is a write-once, read-millions system: a post is stored once and then has to show up in millions of feeds — Twitter pre-built those feeds when a tweet was written, X's For You feed is assembled when you open it.

+ The whole system in one paragraph

X stores every post once, then must show it in millions of feeds, so reading is the hard part. Twitter (2012–2017) did that work up front: it copied each new tweet's ID into every follower's ready-made timeline in memory, so opening the app was one lookup. X's For You feed is instead built fresh each time you open it.

143,199
tweets in a single second — Castle in the Sky, Aug 2013[1]
300K+
home timeline reads a second (Nov 2012)[2]
30B
tweet deliveries into timelines a day (Nov 2012)[2]

In this lesson

3 chapters · ~7 min · a quick check in each

Everything is on this page — just scroll down ↓

Chapter 1 of 3

The whole system

1
Requirements

What it must do — and how well

What the system must do (yellow) and how well (blue). People read far more than they post, and that drives most of the choices that follow.

ⓘ Details & sources

Yellow = what the system must do. Blue = how well it must do it (with the year of each number).[2][1][5][10]

Post a tweet;followers see itwithin seconds.Open the app: thehome timeline loadsinstantly.Every tweet gets aunique ID that sortsby time.For You: mix inposts from peopleyou don't follow.300K+ timeline readsa second (2012).A tweet reaches 1Mfollowers in ~3.5 s(median, 2012).Spikes of 25×normal, with no blip(2013).One broken piecenever takes thewhole site down.
2
Architecture

Post a tweet, build a timeline

A tweet is stored once (top) and its ID copied into each follower's prebuilt timeline (middle). For You is assembled on each request (bottom), so nothing is copied per follower.

ⓘ Details & sources

Top: the write path. Middle: the prebuilt home timeline (Twitter, 2012–2017). Bottom: For You, built per request (2023 → 2026). How X builds the Following tab today isn't published.[2][1][9][12]

Watch it happen:
Post a tweet — the write path (2012–2017)Home timeline, precomputed (2012–2017)For You (2023 → 2026 code)post1new ID2store3fan out4who follows you?4append the ID5openread IDshydrateFor YourankYour apppost · scrollSnowflake64-bit, time-sorted IDWrite APItakes every new tweetTweet storestored once, shardedFanout serviceID → every followerSocial graphFlock: who follows whomTimeline cacheRedis: ≤ 800 IDs eachTimeline serviceone lookup, 1 msTweets + usersIDs → text, authorThunderrecent posts, in RAMHome Mixergather · rank · mixPhoenixfind + score posts
clientserviceworkercachedatabase dashed border = simplified model
12345
Step 1 of 5

You post a tweet. It goes to the write API.

Curious? Go deeper+ 1 optional
3
Pipeline

Under every box: network, data centers, services

A request enters Twitter's own network near you, rides its backbone to a data center, and services call each other through one shared library that routes around failures (2013).

ⓘ Details & sources

Twitter's infrastructure as its engineers described it (2012–2017). What X runs today isn't published.[9][28][1]

Your phoneapp or browser1enterNearby POPfront ends, 5 continents2carryOwn backbone60% of all traffic3routeData center100,000s of servers4callServicesFinagle: failover, LB5switchDeciderfeatures on/off, live6

6 steps. Follow the flow one step at a time — what happens first, and what comes next.

Quick check

Twitter made 30B tweet deliveries into timelines a day (2012). About how many deliveries a second is that?

Pick one — or just keep scrolling, it's not graded.

Keep going — it's free

Create your free account to unlock the rest of X / Twitter's system design, keep your progress and pick up right where you left off.

  1. 2Posting & timelines
  2. 3Growth & failures
Questions & comments

Ask anything about this system, or share how you'd design it.

Log in to join the conversation