Design a News Feed (Twitter Timeline), stage 1 of 9: model
What the numbers say
Twitter reported about 30 billion timeline deliveries a day from about 400 million posts. Each timeline entry needs about 20 bytes: a post ID, the author's ID and a few flag bits.
System so far· 6 parts
Select a component to see what it is responsible for and which state it owns.
- 1Authors → Write API: Post
- 2Write API → Post store: Store post
- 3Readers → Timeline service: GET home timeline
- 4Timeline service → Post store: Hydrate; large accounts' recent posts
What you need to know
0 of 3 checks done
Fan-out is the multiplication of one event into many deliveries: one post, many followers' timelines. The work can happen at write time (when the post is made) or at read time (when a timeline is loaded). See Fan-out on write and fan-out on read.
Which is cheaper depends on how often each side happens. Work belongs on the rarer side.
Work it out
300,000 timeline reads a second, and about 6,000 posts a second at peak. Roughly how many reads per post?Work it out
30 billion timeline deliveries a day from 400 million posts. On average, how many timelines does each post reach?Work it out
Each user's timeline keeps 800 entries of about 20 bytes. About how many terabytes for 150 million users (one copy)?