Lesson 12 of 15
37. Design a News Feed

Score yourself

3 min read+10 XP

Score yourself

Give yourself 0, 1 or 2 points per row.

Area0 points1 point2 points
RequirementsStarted drawingPost, follow, feedRanking, celebrities, freshness and no-repeat scrolling agreed
EstimatesNoneNumbers, not used laterFan-out write volume and celebrity cost drove the design
API and dataSkippedAPI or tablesFeed API with cursor; posts, follows, feed cache of IDs
High-level designOne query per feedPush or pull onlyHybrid, inactive skipping, celebrity pull, ranking and hydration walked
Deep diveHand-wavedOne topicCelebrity problem, ranking pipeline or snapshot pagination with numbers
Trade-offsNone namedNamed when askedRaised unprompted (freshness vs cost, threshold, cache size)
CommunicationLong silencesMostly clearThought out loud, checked in, managed time

12 to 14: strong hire signal. 8 to 11: solid, polish the weak rows. Under 8: redo the round in a week, timer on.

The bar: fresher vs SDE-2

FresherSDE-2
Fan-outPush or pullHybrid with threshold, inactive skipping, backfill on follow
DataFeed table of postsFeed cache of IDs, time-sortable IDs, hydration
RankingNewest firstCandidates → score → rules → hydrate
PaginationOffsetSession snapshot with cursor, "new posts" banner
FailureNot mentionedRebuild feeds by pulling; cache shard loss handled

Common mistakes

  • Pure fan-out on write, with no plan for accounts with millions of followers.
  • Storing full posts in every feed instead of IDs.
  • Joining follows and posts in SQL on every feed load.
  • Offset pagination over a ranked, changing feed.
  • Fanning out to users who haven't opened the app in months.

Quick check

Five questions on this chapter. Pick an answer, then check it.

quiz