How to build skill-based matchmaking (SBMM) in Nakama
In multiplayer games, players often have a better experience when grouped with others with similar skill profiles. A strict skill window can leave players waiting indefinitely if few opponents are nearby in rating, so a good matchmaker progressively widens that window the longer a player waits. In this guide, we’ll walk through how to write that kind of skill-based matchmaking logic in Nakama’s Go runtime.
Prerequisites #
This guide builds directly on Nakama’s default matchmaker. Read Matchmaker first for an overview of tickets, properties, queries, and how the matchmaker pool and pass cycle work.
Where this guide fits #
Matchmaking in Nakama is a repeating batch process, and it runs in six steps. The full sequence is covered in How matchmaking works:
- Your game client submits a ticket.
- Nakama adds the ticket to the pool.
- On a fixed timer, Nakama checks everyone currently waiting in the pool and forms whatever matches it can. This check is called a pass.
- Nakama notifies the matched players.
- Create the match.
- Join the match.
This guide is about step 3: write a custom matchmaker processor that widens a player’s search radius the longer their ticket waits.
Define your matchmaking rules #
Take a 1v1 arena duel game. Every player carries a skill rating, or MMR, and the matchmaker looks for an opponent close to that rating. The longer a player waits, the further out it’s willing to look.
For a player with skill rating MMR of 50, these are the acceptance bands we’d honor, from narrowest to widest:
- Best: an opponent within 100 points, so a MMR of 0 to 150.
- Second best: an opponent within 500 points, so a MMR of 0 to 550.
- Third best: an opponent within 1000 points, so a MMR of 0 to 1050.
- Last resort: anyone in the queue.

Progressively expand the search with a matchmaker processor #
This guide customizes the matchmaking logic to widen the search server-side, which also keeps match selection authoritative: players can’t widen their own search radius or spoof a better match by tampering with the client.
To use your own logic for making the matches, you take over the pass via the RegisterMatchmakerProcessor function.
Register the function in main.go:
| |
progressiveMatchmakerProcessor receives the whole pool of tickets inside entries and can determine exactly which players should match in each pass.
The processor runs once per matchmaker.interval_sec, 15 seconds by default, and you can set it to whatever suits your game. A ticket that goes unmatched is handed back to you on the next pass, a little older each time.
That gives us a natural way to implement progressive widening. The passes are already a clock, ticking once per interval. For example, with the interval set to 5 seconds, our match rules map onto the passes like this:
- First pass: waited under 5s, search a MMR radius of 100. Best case.
- Second pass: waited under 10s, widen to a radius of 500.
- Third pass: waited under 15s, widen to a radius of 1000.
- Fourth pass onwards: waited 15s or more, no limit, match with anyone. Last resort.

So the search radius can be expressed relative to how long a ticket waits to be matched:
| |
You’ll call searchRadius for each ticket in the next section, when you build the sorted list of players.
Determine matches on each pass #
So far we’ve looked across passes, where each pass of the processor gives a waiting ticket a wider radius than the last. Now let’s zoom into a single one. In a single pass, Nakama hands you the whole pool of tickets at once. Your job is to decide which of them pair up.
Put simply, the logic is two steps: order the pool by skill rating, then pair adjacent players if the skill difference between them fits inside either one’s radius.
Sort the pool by skill rating #
Before anything can be sorted, each entry needs its two numbers: the player’s rating, and the radius that comes from how long the ticket has waited.
| |
Pair adjacent players #
Now the list is ordered by skill rating, a player’s nearest possible opponent is already an immediate neighbor. You’ll walk the sorted list. Take the skill difference between each pair of neighbors. If either player accepts the difference, they match. If neither does, the sweep moves along one place and tries the next pair.
| |
You’ll return matched tickets. Entries not matched stay in the pool and come back next pass with a wider radius.
Full progressiveMatchmakerProcessor code
#
Here’s the complete processor code in one place. See Trace the processor through two passes below for a worked example of it matching tickets.
| |
Things to watch out for #
Setting the threshold values #
A ticket is only ever evaluated once per interval, at ages spaced matchmaker.interval_sec apart. At a 5-second interval, a ticket might be checked at age 4s, then not again until age 9s, then 14s, skipping every age in between.
A single threshold at or above the interval isn’t enough. Thresholds also need to be spaced at least one interval apart from each other. With a 5-second interval, thresholds of 5, 6, and 7 seconds each clear the interval on their own, but a ticket checked at age 4s jumps straight to age 9s, crossing the 5 and 6-second thresholds in the same evaluation. The 6-second band never gets to apply by itself.
Validate ticket properties #
The processor above reads the rating with a bare type assertion, entry.GetProperties()["mmr"].(float64). Properties come from the client. Check the value in your production code:
| |
Trace the processor through two passes #
Take a pool of three. The processor interval is 5 seconds. In the trace below, i is the position in the sorted list sweep.
| |
The 400-MMR player has waited two intervals, so their current search radius becomes 1000. The 800 point gap between this player and the 1200-MMR player is acceptable for the 400 player. The 1200-MMR player queued one interval ago, is still on a smaller acceptance radius of 500, and refuses that gap. Since in our logic acceptance is one-sided, the match forms.
The 3000-MMR player is left over in this pass. Five seconds later the next pass runs. The 3000 ticket has now waited 15s, which puts it in the last resort band, so it accepts anyone. Two fresh tickets have joined the pool since, both on the tightest radius because they’ve barely waited:
| |
At i=0 the two new tickets are 520 points apart and both are still on a radius of 100, so neither accepts and the sweep moves along one place rather than stopping. At i=1 the gap is far larger, 2300 points, and it matches anyway, because the 3000 player has run out of patience and will take any opponent.
Additional links #
- Matchmaker
RegisterMatchmakerProcessorruntime function reference
