Preparing your design workspace

Loading the problem and your latest saved attempt…

Design a Following News Feed Service

Design a scalable reverse-chronological feed for posts from authors a user currently follows.

Problem statement

The interview source asks for a Twitter-style system with both a global feed and a follower feed, then follows up on relational versus non-relational databases, why PostgreSQL may fit, alternative stores, entities, and object-oriented responsibilities.

For this exercise, assume users publish short immutable public text posts, follow or unfollow authors, page through a reverse-chronological global feed of all retained public posts, and page through a separate reverse-chronological feed containing posts from authors they currently follow.

Publish retries must create one post.

A cursor must keep a stable membership snapshot: concurrent publishes and asynchronously materialized pre-boundary entries must not make it repeat or permanently skip an item that was eligible when its first page opened; entries that become eligible later appear only on a fresh first-page read.

Subsequent follower-feed reads must exclude authors the user has unfollowed. The global feed must remain bounded without a single global write sequencer or a scan of every post. The system must serve ordinary authors and authors with millions of followers without making every publish operation unbounded.

Identify the durable database records and indexes, justify the database choices, and define entity behavior plus clear domain or service responsibilities for publishing, follow state, global-feed reads, follower-feed reads, and fanout policy.

Recommendation ranking, ads, comments, reactions, reshares, search, media processing, private-account approvals, and notification delivery are outside scope.

What to build

  1. For this exercise, an authenticated user can idempotently publish an immutable short text post and receive a stable post ID.
  2. For this exercise, a user can follow or unfollow another author, and subsequent feed reads use the current follow relationship.
  3. For this exercise, a user can page through a deduplicated reverse-chronological feed of retained posts from currently followed authors.
  4. For this exercise, any reader can page through a deduplicated reverse-chronological global feed of retained public posts without one globally serialized write path.

At scale

  • For this exercise, assume 30 million daily active users, peaks of 5,000 post publications and 150,000 combined global- and follower-feed reads per second, and highly skewed read traffic.
  • For this exercise, assume an ordinary author has hundreds of followers while a popular author can have up to 20 million followers.
  • For this exercise, target 300 milliseconds p95 for healthy feed reads and 10 seconds p95 for an ordinary new post to become eligible in follower feeds.
  • For this exercise, retain posts for one year, keep acknowledged posts durable through a single-zone failure, allow at-least-once event delivery, and make derived inbox entries rebuildable from post and follow authorities.