← Create New Paste

Designing an Online Multiplayer Game Matchmaking Service (System Design Interview)

6 views
"Design matchmaking for an online game" is a favorite at gaming companies and a good general prompt because it combines queues, real-time state, fairness trade-offs, and latency. The goal is simple to state: put players into balanced matches quickly, with good network quality. Clarify requirements Functional: a player (or a party of friends) requests a match for a mode such as ranked 5v5; the service groups players into teams, picks a game server, and tells all clients where to connect. Players can cancel. The system tracks skill ratings and updates them after matches. Non-functional: median wait under 30-60 seconds; matches balanced by skill; low ping (players matched within a region); handle peak traffic of hundreds of thousands of concurrent searchers; no player placed in two matches at once. High-level components 1. Matchmaking API: accepts ticket requests (player ids, party, mode, region, skill rating, latency measurements to nearby data centers) and returns a ticket id. 2. Ticket store: an in-memory store such as Redis holding active tickets, partitioned by mode and region. 3. Matcher workers: run in a loop per pool, pulling tickets and forming matches. 4. Game server allocator: reserves a dedicated server in the chosen data center. 5. Notification channel: WebSocket or push to tell clients "match found, connect to X." 6. Rating service: updates skill (Elo, Glicko, or TrueSkill-style) when results come in. The matching algorithm Bucket tickets by skill rating. Each ticket starts with a narrow acceptable range, say plus or minus 50 rating points, which widens over time spent waiting. A matcher repeatedly takes the oldest ticket, searches for compatible tickets within the current range and the same region, and forms a match when it has enough players. For parties, treat the group as one unit with an averaged or max-weighted rating and fill remaining slots around it. Then split players into two teams that minimize the rating difference; a greedy assignment by descending skill is usually good enough. This "widening window" is the key trade-off to discuss: wait time versus match quality. Low-population modes or very high-skill players will need wider windows or cross-region matching. Consistency A ticket must not be claimed by two matchers. Partition pools so each one has a single matcher owner, or claim tickets atomically (a Lua script or compare-and-set in Redis). If server allocation fails, return the tickets to the pool with their original timestamps so players don't lose their place. Scale and reliability Pools are naturally sharded by mode and region, so you scale horizontally by adding matcher workers per pool. If the ticket store crashes, clients can resubmit; tickets are short-lived, so durability matters less than availability. Log every match decision to an analytics stream to tune fairness later. Closing the answer Summarize the trade-offs: wider ranges mean faster but less fair matches; strict regional pools mean low ping but longer waits. Practicing this structure out loud pays off, and Linkjob AI (https://linkjob.ai) can provide real-time help during live job interviews and technical interviews if you want support keeping a design discussion organized.
Created Nov 17, 2026 13:58 Expires Nov 17, 2027 13:58