Easy · Games
Leaderboards
Players send their score at the end of every match and open the top-100 table all day. Everyone looks at the same top 100, which makes that one answer extremely popular. A tournament final will make it much worse. Practise this easy system design problem for free with a Google or GitHub account.
The brief
Players send their score at the end of every match and open the top-100 table all day. Everyone looks at the same top 100, which makes that one answer extremely popular. A tournament final will make it much worse.
Think of a global high-score table.
Users, scale and requirements
- Who uses it
- 8 million players a month
- Audience in plain numbers
- 8,000,000 people per month
- Normal peak
- ≈ 6,000 requests per second
- Request mix
- Read: 85%; Write: 15%
- Speed for 99 of 100 requests
- Read: ≈ 300 ms; Write: ≈ 300 ms
- Successful requests
- 99.9%
- Data safety
- At most 1 minute of writes may be lost.
- Monthly budget
- ≈ $20,000
- Data at rest
- ≈ 0.1 TB
- Where users are
- North America: 50%; Europe: 30%; Asia Pacific: 20%
- Home region
- North America
- Waiting deadlines
- Read: 900 seconds; Write: 3,600 seconds
≈ marks an approximation, just as in the game. Waiting deadlines measure the age of queued work and are separate from interactive response time.
- One score record is about 100 bytes (approx.).
Questions that shape the design
How fresh must the top 100 be?
Five seconds behind is fine. Nobody notices.
Does a player need to see their own new score and rank immediately?
Their own score should show within a second or two. Everyone else can wait a few seconds.
Can we lose a score?
Rarely and only for the last minute. A lost score is a very unhappy player.
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.
20:00 · Hot key
One item gets a huge share of traffic: a celebrity profile, one product, one merchant.
Affected share: 50%. Duration: ≈ 3,600 seconds.
20:30 · Viral spike
A post blows up. Traffic climbs to several times normal within minutes.
Traffic reaches 5 times the scheduled load; rises over 600 seconds, holds for 3,600 seconds and eases over 3,600 seconds.
What a strong design has to handle
- Half the players are asking for the exact same page. Do they each need a fresh answer?
- A five second copy is slightly stale. Players accept that for a global table, and the saving is enormous.
- The player's own rank skips the edge copy, so it stays fresh but costs the origin a lookup.
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
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.
- Easy
Comments and likes
Under every post sits a like counter and a comment list. Millions tap the heart on the same famous post at the same moment. Showing the exact number is not essential, but showing the person their own like is.
- Hard
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.
- Hard
Black Friday marketplace
Once a year a marketplace puts thousands of deals live at the same minute. Millions browse and search, a few doorbuster items get hammered, and a smaller crowd checks out. A payment must never be taken twice, and the day must survive the card processor having a bad hour.