Skip to content

Design a News Feed (Twitter Timeline), stage 2 of 9: decide

When does the multiplication happen?

Somebody has to combine "one author" with "many readers". Choose where.

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 2 checks done
  1. The two strategies:

    Fan-out on write (push)Fan-out on read (pull)
    Postinginsert into every follower's liststore the post once
    Readingfetch one listfetch every followed account's posts, merge
    Cost lands onwritesreads
  2. Work it out

    With pull, each of 300,000 reads a second fetches recent posts from the ~200 accounts its reader follows. About how many lookups a second is that?
    lookups per second