All problems

News Feed / Timeline

Fan out posts to millions — without melting on reads.

medium~20 min Free Simulator · +110 ptsTheory +45 pts
The build

Serve hot timeline reads while a celebrity post triggers a fan-out storm and the DB stumbles.

Fan-out on write is bursty and huge; a queue must absorb it so it never lands on the posts DB synchronously, while cached timelines keep reads fast.

Components in play

  • Timeline cacheMaterialised feeds served on read.
  • Feed APIBuilds and returns the home timeline.
  • Fan-out queueBuffers the write/fan-out spike off the DB.
  • Posts storeDurable home for posts.

Graded on these SLOs

  • ≥ 98.00%Feeds load
  • ≤ 120 msFeed p99
  • ≥ 12k rpsSustain reads
  • ≤ 90%No redline
  • ≤ 9Footprint
Base 12,000 rps40s run 3 scripted failures

The brief

Design a home timeline like Twitter/X or Instagram. Users follow others and see a feed of recent posts. The hard parts: feeds must load fast, and a single celebrity post may need to reach tens of millions of followers.

Functional

  • Post content; follow/unfollow users
  • Render a home timeline of followed users' posts
  • Reasonable recency/ranking

Non-functional

  • Feed reads are extremely hot and latency-sensitive
  • Fan-out must handle celebrity accounts
  • Eventually-consistent is acceptable

Read the deep dive

18 min read

A home timeline looks deceptively simple: users follow people, and they see recent posts from those people, newest-first. The trap is that the two operations pull in opposite directions. Reads are enormous and latency-sensitive — every app open hits the feed, and a slow feed is a dead product. Writes are cheap individually but catastrophically amplified: when an account with fifty million followers posts once, that single write potentially needs to touch fifty million timelines. You cannot optimize one side without paying for it on the other, and the whole craft of this problem is choosing where to pay. This guide walks from a blank page to the reference architecture the SysGym simulator grades you against: a hybrid fan-out feed with a materialized timeline cache, an asynchronous fan-out queue, a replicated feed API, and a posts datastore. The simulator pushes 12,000 feed reads per second, ramps to 1.6x at peak hours, kills a feed-API node, triples offered load with a celebrity post, then stalls the posts database outright and finally slows it 8x. Throughout, it holds you to a five-part contract: availability at or above 98 percent, a 120ms p99, at least 12,000 rps of sustained throughput, peak saturation at or below 0.9, and a cost footprint at or below 9 provisioned units. Every choice below is justified against those targets — and the reference design clears all five (98.8 percent availability, a 48ms p99, roughly 23k rps served, 30 percent peak saturation, 7 cost units).

Warm-up: design decisions

Optional theory to prime the calls a senior engineer would make before you build.

Pro

Run first, save progress later

The simulator is open without an account. Create one after your run to reveal the score, take the quiz and keep your progress.

  • AI design coach on your canvas — pins failure points & over-engineering
  • Honest AI design review on every run
  • All 12 problems + unlimited chaos simulator
  • Points, levels & leaderboard
Sign up free