Easy · Media and streaming
News site
You run a news site. Millions read the same few stories, and when something big happens almost everyone opens the same page in the same minute. Editors publish all day, and readers expect fresh headlines. Practise this easy system design problem for free with a Google or GitHub account.
The brief
You run a news site. Millions read the same few stories, and when something big happens almost everyone opens the same page in the same minute. Editors publish all day, and readers expect fresh headlines.
Think of a news site like the BBC or CNN.
Users, scale and requirements
- Who uses it
- 20 million readers a month
- Audience in plain numbers
- 20,000,000 people per month
- Normal peak
- ≈ 8,000 requests per second
- Request mix
- Read: 95%; Search: 3%; Analytics event: 1%; Write: 0.5%; Sign-in: 0.5%
- Speed for 99 of 100 requests
- Read: ≈ 350 ms; Search: ≈ 500 ms; Write: ≈ 350 ms; Sign-in: ≈ 1,000 ms
- Successful requests
- 99.9%
- Data safety
- At most 1 minute of writes may be lost.
- Monthly budget
- ≈ $44,000
- Data at rest
- ≈ 4 TB
- Where users are
- North America: 40%; Europe: 40%; Asia Pacific: 20%
- Home region
- Europe
- Waiting deadlines
- Read: 900 seconds; Search: 900 seconds; Analytics event: 3,600 seconds; Write: 3,600 seconds; Sign-in: 900 seconds
≈ marks an approximation, just as in the game. Waiting deadlines measure the age of queued work and are separate from interactive response time.
- A page is about 4 KB of data per request in the game (approx.); images are served separately.
Questions that shape the design
How fresh must the front page be?
A minute behind is fine. A headline that is an hour old is not.
Do readers log in?
Mostly not. Only a small group of subscribers and editors sign in.
Are most readers reading different stories?
No. A handful of stories get most of the views, especially during breaking news.
What happens if the site goes down during a big story?
Readers go elsewhere, and the editors are very unhappy. Breaking news is exactly when it must work.
The traffic day
Traffic concentrated in working hours. The clock covers 00:00 to 24:00 in the home region. Events add pressure on top of that normal traffic.
13:00 · Flash crowd
A scheduled launch brings a sudden rush of requests.
Traffic reaches 25 times the scheduled load; rises over 30 seconds, holds for 900 seconds and eases over 1,800 seconds.
09:00 · 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
- Almost everyone reads the same few pages. How could you answer them without asking a database each time?
- A one-minute cache means a correction can take up to a minute to appear. Clearing the cache on publish fixes that for important stories, at the cost of extra work for editors.
- Collapsing misses stops the stampede after a cold start, but one slow origin request now makes every reader of that page wait.
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
- Medium
Music streaming
People search for songs, build playlists and press play. The audio is the heavy part, and a hit song is played by millions at once. Playback must not stutter, even when part of your system fails.
- Medium
Short-video feed
People swipe through an endless feed of clips of 10 to 30 seconds. The next clip must already be on the phone before the swipe. One clip can suddenly get millions of views, and every view is a signal that picks what to show next.
- Hard
Maps and routing
You run a maps app with places, routes and live traffic. Map pictures never change much, but route lookups, place search and traffic from moving phones do. Soon a whole new continent will start using it. Keep maps fast everywhere without paying to serve the same picture twice.
- Easy
Photo sharing
You are building a photo app. People post pictures and everyone else scrolls through them. Almost all the traffic is people looking at photos, and the photos take up far more room than anything else you store.