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
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 2 checks done
The two strategies:
Fan-out on write (push) Fan-out on read (pull) Posting insert into every follower's list store the post once Reading fetch one list fetch every followed account's posts, merge Cost lands on writes reads 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?Check
Timelines could hold full copies of posts or just post IDs. What happens to copies when the author deletes a post?