SysDesignPrep.com
Interactive concepts

Matchmaking queues: wait time vs match fairness, an interactive simulator

A matchmaker trades two things players care about: how long they wait and how even the match is. Requiring close ratings makes fair games but leaves players far from the average, the very good and the new, waiting for opponents who rarely come. Accepting anyone makes instant, lopsided games. The common answer is a window that starts narrow and widens the longer a player waits.

The playground runs fifteen minutes of a one-versus-one queue with Elo-style ratings. Compare the three windows at a busy time and at 3 a.m., and click one to see who waited.

One player joins the queue a second, with ratings around 1500; anyone unmatched after 120 seconds gives up. A strict 50-point window makes near-even matches, the underdog winning 47% of the time, but 1.3% of players give up, all of them far from 1500, where few opponents exist, and 1 in 20 matched players waits 32 s or more. A wide 400-point window matches almost everyone at once. But its average gap is 171 points, and the underdog wins only 29%. Starting strict and widening by 20 points a second gets most of both: 0.1% give up, the 95th percentile wait is 13 s, and the underdog wins 42%.

WindowMedian wait95th percentileGave upRating gapUnderdog wins
Strict: who waited, by rating, over 15 minutes
0s30s60s90s120s7001100150019002300
gap up to 5051 to 150over 150gave upAcross: rating. Up: seconds waited. Click a row to chart that window.

Fair, fast, or both

With a player arriving every second, a strict 50-point window gives near-even games, the underdog winning about 47% of the time. But the players who give up are all far from the middle of the rating curve, and 1 in 20 matched players waits half a minute or more. A fixed 400-point window matches almost everyone within seconds, at an average gap of 171 points: the underdog wins only 29%. Widening from 50 points by 20 a second keeps most games close, the underdog winning 42%, while nobody waits long.

At 3 a.m., with a player every ten seconds, the strict window loses 28% of players to the queue. Widening still matches almost everyone, but the games are less even: when the population is thin, the honest choice is between waiting and fairness, and the window decides how much of each.

Ratings and real matchmakers

  • Elo predicts a 400-point favourite wins 10 times in 11 and moves both ratings after each game by how surprising the result was. Glicko and TrueSkill add an uncertainty per player, so new players’ ratings move fast and settle as evidence grows.
  • More than rating: real matchmakers also weigh latency to the server region, party size and team balance, and sometimes recent losing streaks.
  • Batching: instead of matching greedily as players arrive, many collect a pool every few seconds and solve for the best overall pairing, which leaves fewer stranded outliers.
  • Scale: queues are partitioned by game mode and region, and players are bucketed by rating so the search for a partner checks nearby buckets, not the whole queue.

Elo and an expanding window in code

def expected(r_a, r_b):
    """Chance that a player rated r_a beats one rated r_b."""
    return 1 / (1 + 10 ** ((r_b - r_a) / 400))

def elo_update(r_a, r_b, a_won, k=32):
    e = expected(r_a, r_b)
    s = 1.0 if a_won else 0.0
    return r_a + k * (s - e), r_b + k * ((1 - s) - (1 - e))

def window(waited_s, start=50, per_s=20, cap=400):
    """How far apart in rating a player will accept, after waiting this long."""
    return min(cap, start + per_s * waited_s)

def can_match(a, b, now):
    gap = abs(a.rating - b.rating)
    return gap <= window(now - a.joined) and gap <= window(now - b.joined)

In a system design interview

For a matchmaking service, describe the queue and the trade-off: “Players enter a queue partitioned by mode and region and bucketed by rating. Every second a matcher scans each bucket and its neighbours, pairing players whose rating gap fits both of their windows; windows start at 50 points and widen with wait time, so p95 wait stays under 30 seconds even off-peak. Ratings use Glicko-2 and are updated by a consumer of game results.” Expect the follow-ups: what happens when a matched player does not accept, how to avoid two matchers grabbing the same player, and smurf accounts.

Read the guide to matchmaking and skill rating or multiplayer game servers, see fair queuing for another kind of waiting-line trade-off, or watch a strong candidate design a matchmaking service.

Questions people ask

How does matchmaking work in online games?

Players join a queue for a game mode and region, and a matcher repeatedly searches for groups whose skill ratings, latency and party sizes fit together. Most matchers accept a narrow rating gap at first and widen it the longer players wait, balancing match quality against queue time.

What is an expanding search window?

A rule that lets the acceptable rating difference grow with time spent in the queue, for example starting at 50 points and adding 20 per second up to 400. Most players are matched quickly and fairly, while players with rare ratings still get a game eventually.

How does the Elo rating system work?

Each player has a rating; the expected score of A against B is 1 / (1 + 10^((Rb - Ra) / 400)). After a game, each rating moves by a factor K times the difference between the actual and expected result, so upsets move ratings a lot and expected wins move them little.

What does a 400-point Elo difference mean?

The higher-rated player is expected to win about 10 games for every 1 the lower-rated player wins, a 91% expected score. A 100-point gap is about 64%, and a 50-point gap about 57%.

Why do high-rated players wait longer for matches?

Ratings are roughly bell-shaped, so there are few players near the top and bottom. With a narrow window, those players rarely find an opponent in range, which is why matchmakers widen windows over time or batch players to find the best available pairings.

What is the difference between Elo, Glicko and TrueSkill?

Elo keeps one number per player. Glicko adds a rating deviation that shrinks as a player plays, so new players’ ratings move quickly. TrueSkill extends similar ideas to teams and multiplayer games. All estimate skill from results; matchmakers then use those estimates to form fair games.

How do you scale a matchmaking service?

Partition queues by game mode and region, bucket players by rating so each search only checks nearby buckets, run matchers per partition, and make claiming players atomic, for example with a compare-and-set in Redis, so two matchers cannot place the same player in two games.