Design league-of-legends backend: system design interview for a large scale systems

Image for post
Image for post
https://technology.riotgames.com/news/architecture-league-client-update

Problem

Scale estimation:

High level

  1. Match history/analytics
  2. Game server
  3. Anti-cheat

Important Design Considerations:

  1. Client game state can not be trusted (to avoid cheaters and bots)
  2. Human reaction time 200–400ms and 100–150ms for professional gamers (visual and audio signals). But my assumption is that in order to make a smooth picture on the screen we need to target 1/5 th of that value
  3. The game should be scalable to 10x peaks in a high demand hours

Capacity Estimation and Constraints

Given that 350k simultaneous matches with an assumed median of 30minute match that gives us 200 RPS to Auth service which is not super challenging to design and scale. Even on 10x load 2k RPS is not a super high load.

  1. Low latency game updates (<20ms) champ coordinates, abilities
  2. Server state synchronization (no client state)
  3. 50 RPS per one client (50 updates once per 20ms) or 500 RPS per match
  4. Given (4) we could host 2–20 matches per compute node (1k — 10k RPS) which give us 3.5k compute nodes per region
  5. Approx only game server infra will cost $100 * 3.5k = $350k / month

Approaches and trade-offs

Solution 0: Since all state and data are grouped by match this is super easy to linearly scale with the number of servers. Given generated match_id we could use a hashing function/registry to lookup specific hosting server coordinates (dc/az/ip) and route clients traffic. Even simpler would be to pin specific live server ip address to the client on matchmaking

Image for post
Image for post

Bonus questions:

  1. How to implement AI/Bots?
  2. How to gracefully handle game server crash?
  3. How to protect a match for a DDOS attack?
  4. Is it possible to p2p client state updates?
  5. How to handle slow clients?

Eventually consistent and eventually practical system engineer https://s10n.substack.com/p

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store