Allocating from your own matchmaker
Claim a Ready server for a match with allocation.v1.
If you run your own matchmaker, or use a hosted one, it asks Aquila for a server once it has a match. One call claims a Ready server and returns its address.
The call
Each zone serves allocation at its own hostname, so a zone keeps allocating while another is down:
curl -sS https://allocate-eu.aquilahosting.com/allocation.v1.AllocationService/Allocate \
-H "Authorization: Bearer $AQUILA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"fleet": "ranked",
"selectors": { "version": "1.4.2" },
"annotations": {
"match": "{\"map\":\"harbor\",\"players\":[\"player-81\",\"player-17\"]}"
}
}'{
"gameServer": "ranked-x7k2p",
"address": "203.0.113.10",
"ports": [{ "name": "game", "port": 20412, "protocol": "UDP" }],
"zone": "eu"
}The key needs the Allocate game servers scope. Give your matchmaker a key with only that scope.
| Field | Does |
|---|---|
fleet | The fleet's name. Fleets of the same name in other zones are allocated through their zone |
selectors | Only servers whose labels match all of these |
labels | Set on the server, so a later allocation can select on them |
annotations | Set on the server for the game to read, such as the match. Up to 4 KiB a value |
Labels and annotations from an allocation are stored under sdk.aquilahosting.com/, where the game reads them through the SDK. A game on the Agones SDK sees them under agones.dev/sdk-.
Selectors
Selectors match a server's labels exactly. A server has:
- The labels of its fleet's template, under the names you gave them.
- Labels the game set through the SDK, under
sdk.aquilahosting.com/. - Labels earlier allocations set, under
sdk.aquilahosting.com/too.
The example selects on a version label in the fleet template, so during a rollout players only land on servers running their client's build.
A game that loads a map and calls SetLabel("map", "harbor") is selected with {"sdk.aquilahosting.com/map": "harbor"}.
Which server you get
Among the Ready servers that match, allocation prefers those on the node already running the most allocated servers. Busy nodes fill up first, which lets quiet nodes empty out when the fleet shrinks.
Two allocations never get the same server, from one matchmaker or several.
Errors
Allocation never waits for a server. Handle these:
| Code | Means | Do |
|---|---|---|
resource_exhausted | No Ready server in the fleet matches the selectors | Retry after a second or two, or try another zone |
not_found | No fleet of that name in this zone | Check the name and the zone's hostname |
unauthenticated | The zone does not know the key | A key reaches each zone when it is created. The console warns when a zone could not be reached, and the next key change retries it |
permission_denied | The key lacks the scope, or the organization cannot run here | Check the key's scopes and the organization's status |
invalid_argument | A selector, label or annotation is malformed | The message names it |
A fleet with an autoscaler keeps a buffer of Ready servers, so resource_exhausted should be rare. If you see it often, raise the buffer or the maximum.
Timeouts and retries
A call that times out on your side may still have claimed a server. That server stays Allocated with nobody on it until the game shuts it down, so have the game end a session no player joins within a minute or two.
After allocation
The game sees the state change to Allocated through Watch, with your labels and annotations. Players connect to the address and the port by name. When the match is over, the game calls Shutdown and the fleet starts a fresh server.
The console shows every allocated server with the name of the key that allocated it and when.
To accept match results from your servers, generate a random token per match in your matchmaker and pass it in annotations, such as "match-token": "…". The server sends it back with its result, and your backend accepts one result per match with that token. See Results for the same pattern with Aquila's matchmaker.