Solved design · 02 of 12 · 10 credits, once

Facebook news feed

Candidate retrieval from precomputed timelines, a ranking model on every load, the social graph behind a cache (TAO), posts fanned out through Kafka.

Template
Facebook news feed
Level
Advanced
Reading time
18 min
Topics
Feed rankingSocial graphCache tiersFan-outKafkaCapacity planning

In the lab Candidate retrieval from precomputed timelines, a ranking model on every load, the social graph behind a cache (TAO). It meets its goals as given (success ≥ 99%, p99 ≤ 500 ms, Apdex ≥ 0.90). Open it to see how it is put together, then push it: 3x traffic, an attack, a flush, a dead replica, and fix what breaks.

1Context and scope

The news feed is the most-loaded page in the product: every open retrieves hundreds of candidate posts for the viewer, scores them with a model, and returns the top ones. Posts are rarer and are pushed into followers’ timelines asynchronously. This design covers the feed and post paths with the social graph behind a read-through cache, based on Meta’s published papers on TAO and feed ranking, scaled to a browser run.

2Goals and non-goals

Goals

  • 5,000 requests a second: 85% feed loads, 15% posts.
  • Success at least 99%, p99 at most 500 ms, Apdex at least 0.90.
  • Posts reach timelines through Kafka with nothing lost.

Non-goals

  • Ads ranking and auction.
  • Comments, reactions and messaging.
  • Multi-region replication of the graph.

3Capacity estimate

QuantityValueHow
Feed loads≈ 4,250/s85% of 5,000
Feed cache64 GB, 50M entries, 5 min TTL, 1M ops/sshort TTL keeps feeds fresh; popularity skew keeps the hit rate high
Ranker2,048 slots, 128 vCPU, 4 ms CPU4,250 × 4 ms ≈ 17 vCPU busy; 4,250 × 20 ms ≈ 85 slots
Social graph calls≈ 1,275/s30% of feed loads need a graph lookup the cache did not cover
Posts≈ 750/sone MySQL write and one Kafka event each
Fan-out256 workers at ≈ 8 msabout 32,000 timeline writes a second of headroom over 64 partitions

The rest of the doc

The design · Key concepts · Alternatives considered · Failure modes and fixes · Try it in the lab · Check yourself · Further reading

Solved design · 10 credits, once

Unlock the Facebook news feed design doc

Every component and why it is there, the capacity numbers behind it, what breaks when you push it and how to fix it, and the same system open in the lab to break and fix yourself. Paid once, on your account.