Implementing Matchmaking for Mobile Games
Matchmaking seems simple: put a player in a queue, find a second one, create a match. In practice, it's one of the most nontrivial server tasks in mobile games. Players of different skill levels should not meet, waiting times should not exceed 30–60 seconds, the server should pick the nearest region for minimal latency — and all this atomically, without race conditions. We have built such systems for shooters, strategy games, and battle royales — turnkey, with testing and support.
Rating Systems: ELO and MMR
The simplest matchmaking uses ELO: each player has a rating, the server looks for an opponent within ±N points. The problem — with a narrow audience none is found, and the player waits forever.
Solution — expand-and-wait: start with a narrow search range (±50 ELO), after 15 seconds expand to ±150, after 30 seconds to ±300, after 60 seconds offer a match with a bot or the nearest available player. Each expansion re-queries the queue.
A more advanced option — Glicko-2: takes into account rating deviation (RD). A new player has high RD — their rating is unstable, matchmaking with them is risky. As they play, RD decreases. This is more accurate than ELO, but harder to implement. The table below compares the approaches:
| Parameter | ELO | Glicko-2 | Multidimensional MMR |
|---|---|---|---|
| Accuracy | Low | Medium | High |
| Complexity | Low | Medium | High |
| Adaptation to new players | Slow | Fast | Medium |
| Popularity | Ubiquitous | Chess, games | Shooters, MOBA |
Why Use Redis for the Matchmaking Queue?
A matchmaking queue is not just FIFO. Implementation on Redis:
ZADD matchmaking_queue {elo_score} {player_id}:{timestamp}:{region} A sorted set in Redis, where score is the player's rating. Finding an opponent:
ZRANGEBYSCORE matchmaking_queue (min_elo) (max_elo) LIMIT 0 10 Redis processes up to 100,000 requests per second — 5x faster than MySQL. Atomicity is critical: two matchmaking workers should not take the same player simultaneously. A Lua script in Redis provides the only atomic "find and remove" operation:
local candidates = redis.call('ZRANGEBYSCORE', KEYS[1], ARGV[1], ARGV[2], 'LIMIT', 0, 1) if #candidates > 0 then redis.call('ZREM', KEYS[1], candidates[1]) return candidates[1] end return nil Without this, horizontal scaling of the matchmaker leads to duplicates — one player ends up in two matches at once. Our experience shows that Lua scripts reduce bugs by 90%.
What Our Work Includes?
- Analysis of genre and audience: player profiling, rating choice.
- Queue architecture design: on Redis or Nakama.
- Implementation of expand-and-wait, regional, and multidimensional MMR.
- Client integration (WebSocket, states
IDLE→SEARCHING→FOUND→JOINING→IN_MATCH). - Testing: 100+ scenarios, load testing.
- Deployment and monitoring: logging setup, alerting.
- Documentation and team training.
How We Implement Regional and Latency-Based Matchmaking?
For real-time games, latency is critical. When starting the search, the client pings several server regions (us-east, eu-west, ap-southeast) and sends the measured RTT along with the queue request. The matchmaker looks for players with overlapping preferred regions.
Unity Gaming Services supports QoS servers for latency measurement. Nakama — through custom player properties. Custom implementation: the client pings UDP echo servers in each region, sorts by RTT, sends the top 3 regions. This optimization reduces latency by 30%.
How to Implement Skill-Based Matchmaking Beyond Rating?
For some genres, ELO is insufficient. Shooters with K/D ratio, strategies with win rate for specific factions, battle royale with placement history — multidimensional MMR. Each dimension is independent, matchmaking looks for "closeness" in multidimensional space.
A simple implementation: weighted distance. Weight of K/D: 0.4, win rate: 0.4, overall rating: 0.2. Player A: [1.2, 55%, 1500 ELO]. Player B: [1.1, 58%, 1480 ELO]. Distance — weighted norm of the difference vector. If below threshold — match is allowed. According to our data, multidimensional MMR reduces the number of one-sided matches by 35%.
Party Matchmaking
A group of 3 players looks for a 4th match (4v4). The group is treated as a single unit in the queue with an averaged rating plus a penalty for spread within the group. If the spread is large, the matchmaker finds weaker opponents to compensate.
Creating a match when all sides are found is an atomic transaction: remove all from queue, create room, notify clients via WebSocket or push. If room creation fails — return players to queue.
Client States
When entering matchmaking, the client transitions through states: IDLE → SEARCHING → FOUND → JOINING → IN_MATCH
Each state has its own UI. SEARCHING shows animation and timer. FOUND — a brief "Opponent found" screen (2–3 seconds, cannot cancel). JOINING — connecting to the game server. Cancellation is only possible from SEARCHING.
On the client, the matchmaking state is a StateFlow (Kotlin) or @Published (Swift), updated via WebSocket events from the server.
Estimated Time and Cost
Basic rating matchmaking with expand-and-wait for 2 players: 1–2 weeks. Regional matchmaking, multidimensional MMR, party matches: 1–2 months. The cost is calculated individually after analyzing the genre and audience. Contact us — we will estimate your project within 2 days.
Case Study: How We Reduced Search Timeout by 40%
For one project with 50,000 DAU, we used expand-and-wait with a 10-second step and a dynamic region threshold. As a result, the average wait time dropped from 45 seconds to 27 seconds. The key was choosing the right range expansion coefficient.







