Unique matches issue


In our game we are running an authoritative match loop, though we handle match creation ourselves using a custom RPC, without using the matchmaker.

Each area of our game can have a single match running, using a unique label. So when a player arrives at that area we do the following:

  1. We query all active matches using the area label:
    const matches = nk.matchList(1, true, query);

    if (matches[0]) {
      response.matchId = matches[0].matchId;
  } catch (error) {}

If a match is active, we return that match.

  1. If not, we go forward and create a new match and return that instead:
  if (!response.matchId) {
    const params = {
      lobbyId: lobbyId,

    const matchId = nk.matchCreate(moduleName, params);
    response.matchId = matchId;

That works perfectly fine unless we initiate two sessions at the same instant, that would be two players pressing the connect button approximately at the same time.

Then the above code may create in some cases two different match instances. We were under the impression that all RPCs are executed in a sequence, isn’t that the case?

Is there a case why the above code will execute in parallel or if that is not the case, then why matchList() running for the 2nd player wouldn’t find the match created just before by the 1st player? Does it take a while for the server to register that match?

Thank you,

@Leonidas We’ve made no guarantee that the requests will be executed in sequence. This would hurt performance of any kind of application server heavily. I don’t think you’d ever want this behaviour in practice anyway. Your particular example only occurs because (1) low user counts, (2) low existing active matches, (3) users who’re attempting to find or create a match in near the same moment.

If you feel this is a real concern for the game design there is a very complex way that I can recommend to achieve a closer outcome to your desired serialized match creation flow but it will hurt server performance.

1 Like

Thanks for the prompt reply! Yes, even though the very complex way isn’t that inviting :innocent:, definitely let us know how that can work. Having single/unique matches per world region is quite important for our game design.