Design a News Feed (Twitter Timeline), stage 3 of 9: model
Trace a post to a follower's screen
An author with 200 followers posts. One of those followers opens the app a few seconds later.
System so far· 9 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
- 3Write API → Fan-out queue: Fan-out job
- 4Fan-out workers → Fan-out queue: Take jobs
- 5Fan-out workers → Social graph: Active followers
- 6Fan-out workers → Timeline cache: Push ID, trim to 800
- 7Readers → Timeline service: GET home timeline
- 8Timeline service → Timeline cache: Page of IDs
- 9Timeline service → Post store: Hydrate; large accounts' recent posts
- Request / response
- Asynchronous
What you need to know
0 of 1 checks done
Tracing a request means following it through each component in order, and noting where the user stops waiting. Everything after that point can be slow or retried without them noticing, but it's also why there's a delay before followers see the post.
Check
With fan-out on write done asynchronously, how long does the author wait after pressing Post?Hydration turns IDs back into content: the read path fetches a page of post IDs from the timeline, then looks up the posts themselves (mostly from a cache). Posts that no longer exist are simply dropped.