Twitter HLD: Fan-Out, the Celebrity Problem, and Merging a Timeline
A Twitter / X news feed system design (HLD): fan-out on write vs read, the celebrity problem, the push-pull hybrid, and assembling a timeline by merging K sorted streams at scale.
Your thumb pulls down and lets go. Before the spinner finishes its first turn, a feed is there: the newest posts from all 800 accounts you follow, in perfect time order. You didn't wait. You never wait. Now look at what you actually asked for. Something had to know which 800 accounts, find their newest posts among billions, sort them, and hand you fifty — in about 100 milliseconds, while 300 million other thumbs pulled down too. The naive version of that ("query every tweet from everyone I follow, order by time, take 50") is a scan of billions of rows run thousands of times a second. It cannot…
What’s inside
Read this one free
Sign in and your first premium article is on us — read Twitter HLD: Fan-Out, the Celebrity Problem, and Merging a Timeline free.