Skip to content

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
1234CLIENTAuthorsSERVICEWrite APIDATABASEPost storeSERVICESocial graphSERVICETimeline serviceCLIENTReaders

Select a component to see what it is responsible for and which state it owns.

  1. 1Authors → Write API: Post
  2. 2Write API → Post store: Store post
  3. 3Readers → Timeline service: GET home timeline
  4. 4Timeline service → Post store: Hydrate; large accounts' recent posts

What you need to know

0 of 3 checks done
  1. 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.

  2. Work it out

    300,000 timeline reads a second, and about 6,000 posts a second at peak. Roughly how many reads per post?
    reads per post