Skip to content
System Designer

Hard · Social and messaging

Social feed

Every person opens the app and sees a feed of posts from the people they follow. Most people have a few hundred followers, but a few have millions, and when they post, millions of feeds must change. The feed must be fast and your own post must show up at once. Practise this hard system design problem for free with a Google or GitHub account.

The brief

Every person opens the app and sees a feed of posts from the people they follow. Most people have a few hundred followers, but a few have millions, and when they post, millions of feeds must change. The feed must be fast and your own post must show up at once.

Think of a home timeline like X or Facebook.

Users, scale and requirements

Who uses it
50 million people a month
Audience in plain numbers
50,000,000 people per month
Normal peak
≈ 60,000 requests per second
Request mix
Read: 80%; Analytics event: 12%; Notification: 3%; Write: 2%; Search: 2%; Sign-in: 1%
Speed for 99 of 100 requests
Read: ≈ 350 ms; Write: ≈ 350 ms; Search: ≈ 500 ms; Sign-in: ≈ 1,000 ms
Successful requests
99.9%
Data safety
At most 1 minute of writes may be lost.
Monthly budget
≈ $170,000
Data at rest
≈ 60 TB
Where users are
North America: 40%; Europe: 30%; Asia Pacific: 30%
Home region
North America
Waiting deadlines
Read: 900 seconds; Analytics event: 3,600 seconds; Notification: 900 seconds; Write: 3,600 seconds; Search: 900 seconds; Sign-in: 900 seconds
Fresh reads
People must see their own changes. At most 0.1% of reads may be stale in the model.
Personal reads
60% of reads are private; a shared public copy cannot answer them.

≈ marks an approximation, just as in the game. Waiting deadlines measure the age of queued work and are separate from interactive response time.

  • About 20 million posts are made per day (approx.).
  • A post is about 1 KB. Media is handled by a different system.
  • Notification speed measures provider acceptance. Device receipt is outside this traffic model; check expiry, provider outcome and retries in the correctness trace before claiming delivery guarantees.

Questions that shape the design

Must the feed be perfectly fresh?

A few seconds behind is fine, except for your own posts, which must show at once.

How many followers does a typical account have?

About 200. A few thousand accounts have over a million.

How often do people read versus post?

Roughly 40 reads for every post. Reading is the hot path.

Are feeds ranked or in order of time?

In order of time to start with. Ranking can come later.

The traffic day

Consumer traffic, busiest in the evening. The clock covers 00:00 to 24:00 in the home region. Events add pressure on top of that normal traffic.

  1. 12:00 · Celebrity post

    A popular account posts, multiplying the work needed to update follower feeds.

    Work multiplier: 25. Duration: ≈ 900 seconds.

  2. 17:30 · Hot key

    One item gets a huge share of traffic: a celebrity profile, one product, one merchant.

    Affected share: 30%. Duration: ≈ 3,600 seconds.

  3. 08:15 · Cache stampede

    The cache empties (restart, purge, mass expiry) and every request rushes to the database at once.

    Recovery window: ≈ 300 seconds.

What a strong design has to handle

  • There are many more reads than posts. Would you rather do the work when someone posts, or when someone reads?
  • Bound fanout for celebrity posts while preserving read-your-writes.
  • Pushing into feeds makes reads very fast but multiplies every post by its follower count. That is cheap at 200 followers and ruinous at 5 million.
  • Merging a celebrity's posts at read time makes reads a little slower but avoids millions of writes. It is the price of treating big accounts differently.

Make a prediction, run a full traffic day, then compare the result. The in-game editorial opens after a finished day and includes measured reference designs.

Concepts to practise

Related problems