Layer 3 · Go deeper · 11 min
Go deeper
Size it, build it, then make the calls an interviewer will push you on.
Back of the envelope
Size it up
Tap through each step of the arithmetic.
How much RAM does the last week of posts need?
How many real-time servers serve 100k searches a second?
What does sending each viewer’s filters to every partition cost?
Build-up · 5 steps
Build the high-level design
One functional requirement at a time, ending with a design that works for one region at moderate traffic.
Step 1 of 5
Search keywords, hashtags, filters
Posts flow through Kafka to an indexer that turns words, hashtags and filters into terms. Hashing by post ID spreads a hot hashtag over all 20 partitions; a query visits every one.
6 interview moments
You’re the candidate
The interviewer pushes on the hard parts. Pick an approach and see how it holds up.
Deep dive 1 of 6
Interviewer
“In the final over, posts arrive 20,000 a second. How do you make each one searchable within a second?”
Your move. Pick an approach:
Deep dive 2 of 6
Interviewer
“Beyond the week in RAM sit 600 billion posts, growing by billions a week. How do you split the index?”
Your move. Pick an approach:
Deep dive 3 of 6
Interviewer
“During Diwali week, “#diwali” matches 70 million posts whose likes change every second. How do you rank Top?”
Your move. Pick an approach:
Deep dive 4 of 6
Interviewer
“A friends-only post must never reach a colleague, and an unfriend applies at once. Where do you enforce visibility?”
Your move. Pick an approach:
Deep dive 5 of 6
Interviewer
“Last over of an India–Australia final. Assume 40,000 searches a second are variants of “ind vs aus”. What do you do?”
Your move. Pick an approach:
Deep dive 6 of 6
Interviewer
“You scroll Top for “#diwali” while likes keep reshuffling scores. How do you serve page 2?”
Your move. Pick an approach:
Build-up · 8 steps
Follow one post, then one search
Three paths at three speeds: a post becomes searchable in about a second, signals and history move in seconds and days, and a query answers in a few hundred milliseconds.
Step 1 of 8
Publish
The post service commits the post and publishes post.created, or an edit or delete, to Kafka, 5.8k events a second and 20k at peak. The post store stays the source of truth.