Design a News Feed (Twitter Timeline), stage 9 of 9: defend it
Defend the hybrid
Your interviewer: "You have two read paths, a queue doing a third of a million inserts a second, and terabytes of Redis. Wouldn't fan-out on read with a good cache be simpler?"
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
"Wouldn't X be simpler?" deserves a numeric answer. Restate the ratio that drove the design, show what the alternative costs in the same units, concede the real costs of yours, and say what would change your mind.
Check
"Use pull with a good cache." Why doesn't caching rescue pull here?