Chapter Seventeen · Problem Eleven

News Feed

Everyone knows the word hybrid. This round asks where its line goes, what one user's cached feed really holds, and what a page promises while new posts land above it.

4 lessons · 45 minutes
The Question

"Design the home feed of a social network: a user sees recent posts from the people they follow."

Most candidates have read about this one, and within two minutes they have said fan-out and hybrid. Everyone knows the word hybrid, and few can say where its line goes or which number put it there. The interviewer has heard the recitation many times, so they wait for the first price.

The round leans on four earlier chapters. Chapter 2's Caching at Scale and When the Cache Hurts matter because the feed ends up living in a cache. Chapter 3's Hot Partitions comes in with one large account's post, and Picking the Partition Key with the split of the post store. Chapter 6's Queues, Logs and Pub-Sub carries the work a post sets off. And the cursor from Chapter 1's API and Data Before Boxes returns, on a list that moves far faster.

This one is pitched at senior, where the question is whether you price each choice or recite it. You face three decisions. You choose between doing the work when a post is written and doing it when a feed is read, and then you deal with accounts that have millions of followers. You say what one user's cache entry holds and how big it gets, which comes down to IDs and not posts, and how those IDs become a page. And you page through a list that changes while someone is scrolling it.

Run it as a rehearsal before you read on. Put 45 minutes on a clock, sketch your answer, and write down one number: how many followers an account has at the point where your design stops pushing its posts. Then hold your version against these lessons. Scope holds the first ten minutes. First Design and Scaling It take ten each, and the deep dives and curveballs get the last fifteen.

The 45 minutes of this problem, lesson by lesson
Scopeminutes 0-10
→
First Designminutes 10-20
→
Scaling Itminutes 20-30
→
Deep Divesminutes 30-45

Lessons in This Chapter