Matchmaking
Queues, tickets, and how a matched game server learns who is in its match.
Aquila's managed matchmaker groups your players into matches and allocates a server for each one. You set up queues in the console. Your game backend creates a ticket per player or party and follows it until it has a server address.
It is optional. A studio with its own matchmaker allocates directly.
How a match forms
- Your backend creates a ticket in a queue, with the players' IDs and attributes.
- Every second, the queue groups compatible tickets into matches, oldest tickets first.
- For each match, Aquila allocates a Ready server from the queue's fleet. The server gets the match as an annotation.
- Every ticket in the match moves to
ASSIGNEDwith the server's address and its team. - Your backend hands the address to its players, and they connect.
When no zone has a Ready server, the tickets go back to searching and keep their place in line. The queue tries again a few seconds later. Keep a buffer of Ready servers with the fleet's autoscaler, so matches rarely wait for one.
Queues
A queue belongs to one fleet, named by fleet name. With fleets of that name in several zones, each match goes to the zone its players reach best (see Zones).
| Rule | Does |
|---|---|
| Teams | How many teams a match has, 1 to 16 |
| Players per team | 1 to 100, and at most 100 players in a match |
| Equal attributes | String attributes every ticket in a match shares, such as mode or region |
| Ranges | Number attributes that must sit close, such as skill. Up to 4 |
| Ticket timeout | How long a ticket searches before it expires. 10 seconds to an hour, 120 by default |
| Short matches | Start a match below full size once its oldest ticket has waited long enough |
| Balance teams | Spread players so the teams' totals of the first range attribute come out close |
| Selectors | Only allocate servers whose labels match |
A disabled queue refuses new tickets. Tickets already searching still match.
Ranges
A range has a starting window, a widening rate and a maximum. A match is built around its oldest ticket: another ticket fits when its value is within the window of the oldest ticket's value. The window starts at its initial size and widens every second the oldest ticket waits, up to the maximum.
With skill starting at ±50, widening by 10 a second up to ±300, a player at 1200 is first matched with players from 1150 to 1250. After 10 seconds of waiting, anyone from 1050 to 1350 fits.
Short matches
Without this rule, a match waits for every team to fill. With it, once the oldest ticket has waited the given number of seconds, the match starts as soon as every team has at least the minimum number of players. Teams fill evenly, so a short match stays as fair as it can.
Tickets
Create tickets from your game backend, never from the game client. The call needs an API key with the Create matchmaking tickets scope, which must stay secret.
{
"organizationId": "…",
"queue": "ranked-duo",
"playerIds": ["player-81", "player-82"],
"stringAttributes": { "mode": "ranked" },
"numberAttributes": { "skill": 1240 },
"latenciesMs": { "eu": 24, "us": 110 }
}- Players. One player, or a party that always plays on one team. A ticket holds at most the queue's players per team. A player is never seated twice in one match, even across tickets.
- String attributes. Every equal attribute of the queue. A ticket missing one only matches others that also miss it.
- Number attributes. Every range attribute of the queue is required. For a party, send one value for the whole party, such as its average skill.
- Latencies. Round trip in milliseconds per zone, as the player's client measured it. See Zones.
CreateTicket returns RESOURCE_EXHAUSTED above 50 tickets a second per organization (bursts of 200), or when the queue already has 10,000 tickets searching. It returns FAILED_PRECONDITION for a disabled queue.
Following a ticket
| State | Means |
|---|---|
SEARCHING | Waiting in the queue |
MATCHED | In a match whose server is being allocated |
ASSIGNED | Done. assignment holds the address, ports, match ID, team index and match token |
EXPIRED | The queue's ticket timeout passed while searching |
CANCELLED | Your backend cancelled it |
Keep WatchTicket open, or poll GetTicket about once a second. WatchTicket sends the ticket at once and on every change, and ends at ASSIGNED, EXPIRED or CANCELLED. It is a stream, so call it through a typed client.
CancelTicket takes a ticket out of the queue, for a player who stopped searching. Once the ticket is MATCHED it can no longer be cancelled.
Tickets are kept for 24 hours, and matches for 30 days in the console's activity list.
In the game server
The allocated server carries the match in an annotation and its ID in a label:
| Aquila SDK | Agones SDK | Holds |
|---|---|---|
sdk.aquilahosting.com/match | agones.dev/sdk-match | The match, as JSON |
sdk.aquilahosting.com/match-id | agones.dev/sdk-match-id | The match ID |
sdk.aquilahosting.com/match-token | agones.dev/sdk-match-token | The match token |
{
"matchId": "d0a43216-8197-487c-9203-81691066507d",
"queue": "ranked-duo",
"teams": [
{ "ticketIds": ["…"], "playerIds": ["player-81", "player-82"] },
{ "ticketIds": ["…"], "playerIds": ["player-17", "player-40"] }
]
}Watch the server's state through the SDK. When it turns Allocated, read the annotation, seat the players as they connect, and call Shutdown when the match is over.
The annotation can arrive a moment after the state change, so read it from the update that carries it. Decide in the game what happens to players who never connect.
Results
Each match gets a random token that only its server and your backend hold. The server reads it from the match-token annotation, and every ticket in the match carries the same one in assignment.match_token. Neither the console nor the fleets API shows it.
To accept results from your servers:
- Keep the match ID and token from the assigned tickets.
- The server posts its result to your backend with the match ID and token.
- Your backend accepts one result per match ID, and only with the token it kept.
A server can then only report the match it hosted, and only once. Aquila never checks the token. Tokens are kept for 24 hours, with the tickets.
Zones
When a queue's fleet runs in several zones, each ticket's latenciesMs decides where its match can go:
- A ticket with latencies only matches in the zones it lists.
- A ticket without any accepts every zone.
- Of the zones every ticket in a match accepts, the match goes to the one whose worst latency is lowest, then to the next if that zone has no Ready server.
Measure latencies from the client to each zone's allocation hostname, allocate-<zone>.aquilahosting.com.