News Feed (Twitter Timeline) System Design

Medium
read-heavy
feed
followers

Show each user a timeline of posts from the accounts they follow.

About this problem

Design the home timeline of a Twitter-style social network. People publish short text posts and follow other accounts. Each person's home timeline shows the recent posts from everyone they follow.

A new post must show up in followers' timelines within seconds, and loading a timeline has to be fast, since it's the first thing people see when they open the app.

Timeline loads are three quarters of the traffic. New posts and follow lookups make up the rest. Load grows level by level toward 10,000 requests per second.

Requirements

  • Publish a short text post.
  • Load a home timeline of recent posts from followed accounts.
  • New posts appear in followers' timelines within seconds.

Scale targets

  • Timeline reads are three quarters of traffic. Posts and follow lookups make up the rest.
  • Load grows each level toward 10,000 TPS.

Traffic

Step up, 100 to 10,000 TPS. The simulator sets this traffic up for you when you start the problem.

CAP trade-off

Favors availability

Followers can see a new post a few seconds late, but the timeline must always load. Small, short-lived differences between users are acceptable.

Practice it

Build it on the canvas, run the traffic, and get scored.