Requirements
“Design a leaderboard for ChessHop” leaves a lot open. So before designing, we ask the interviewer clarifying questions.
Clarifying questions
Here are some questions to ask, with the interviewer’s answers:
- One leaderboard or several? One for each time control.
- Every player, or only the top 10? Every rated player.
- Who can see it? Anyone, without signing in.
- What does a player see about themselves? Their own rank, with the players around them on the leaderboard. Their profile shows their rank in each time control.
- How are ties broken? Whoever reached the rating first is ranked higher.
- How quickly must a new rating show? In real time.
- How many players and games? 20 million rated players in a time control. At the peak, 500 games end a second.
- Can the leaderboard be down? Yes, for a while. But it must never stop games.
Some questions are out of scope for this design. One is how a rating is computed. When a game ends, the game service computes the new ratings. We take them as given. Cheat detection and removing players who have not played in a while are out of scope too.
If you ask a question the interviewer has no answer for, make a reasonable choice and say so.
The requirements
From the answers, we agree on the requirements.
Functional:
- For each time control, the leaderboard lists every rated player with their rank, ordered by rating, highest first. Ties go to whoever reached that rating first.
- Anyone can page through the leaderboard, 50 players to a page, without signing in. A player can jump to their own rank and see the players around it.
- A player’s profile shows their rank in each time control.
Quality attributes:
- Performance: When someone opens a page of the leaderboard or a profile, ChessHop must return it in under one second.
- Performance: When a game ends, both players’ new ranks must show in real time. This applies to open leaderboard pages and to any page or profile loaded after that.
- Scalability: ChessHop must continue to meet both targets with 20 million rated players in a time control, and 500 games ending a second at the peak.
- Availability: If the leaderboard fails, players must still be able to play games.
The second performance requirement says “real time” without a number. Interviewers often state it this way. We will agree on a number with the interviewer once we know how often a page of the leaderboard changes.