The warm buffer and allocate
Starting a game server takes tens of seconds. A warm buffer is a number of units the platform keeps started and idle, so that when a match is ready, one call hands it a server that is already running.
Switch the policy to code mode
The scaling policy lives at .../units/policy. Changing it needs a person's token: a service principal may control units but never the policy.
curl
Code
TypeScript
Code
Python
Code
| Field | Meaning | Default and range |
|---|---|---|
mode | fixed, autoscaled or code | fixed at one unit |
max_units | the most units with a pod at once: warm, allocated, created by key and running | up to the product maximum and your organization limit |
warm_units | ready, unallocated units to keep on top of everything else | 0 to max_units |
default_on_exit | restart, stop or destroy | restart |
idle_action, idle_after_seconds | stop or destroy a unit that signalled idle this long. Never applied to unallocated warm units | none; 60 to 86,400 |
destroy_stopped_after_days | destroy stopped units after this long | 90; 1 to 365 |
ready_timeout_seconds | a unit not Ready this long after its pod started is Failed | 300; 10 to 3,600 |
readiness | auto or signal (Ready only after the unit signals ready) | auto |
rollout | rolling, replace_idle or next_start | replace_idle for code |
spend_cap_cents | the most the extra units may cost in a month before growth is refused | the worst case |
Preview the cost before committing, with the same body, on POST .../units/policy/quote:
curl
Code
TypeScript
Code
Python
Code
A warm unit is billed like any running extra unit: it holds CPU and memory. Every start bills at least 5 minutes. Stopped units are free.
Allocate
POST .../units/allocate takes one ready, accepting, unallocated, draining-free warm unit, preferring the current template and then the longest ready. It sets the unit's labels and user_data when you give them, and the buffer refills in about a second.
curl
Code
TypeScript
Code
Python
Code
- Atomic. Two callers never get the same unit.
Idempotency-Key(optional, up to 64 printable characters): retrying with the same key returns the same unit while it lives (200,replayed: true). Without it, every call allocates a new unit. Always send one from a matchmaker.?wait=deliveredholds the response until the unit's agent has written the allocation files (/zaroz/allocation.json,/zaroz/user-data.json), up to 10 seconds. Without it,unit.allocation_deliveredarrives as an event.if_none:fail(default) answers409 no-warm-unitwithwarm_ready,warm_startingandretry_after_seconds.createcold-starts a new unit already allocated to you and answers202with the unit still starting.- An allocation is never undone. The unit ends by its own exit, a stop or a destroy.
- If the region cannot be reached, the allocation is reverted and you get
503 region-unreachable. Running units keep serving.
The unit in the response has the private_name (<key>.<workload-slug>) and the public_endpoints to send players to.
Rollouts when you ship a new image
replace_idle replaces stale units that are not allocated and not busy, at most a quarter at a time, new unit first. Allocated or busy units are replaced when they end. next_start leaves running units alone and applies the change the next time a unit starts. See rollout rules.
