français : cette page n’est pas encore traduite, la voici en anglais.
Each instance of an app is a sandbox made from the version’s template, so the service in it is already running when it is made. It is in your project’s list of sandboxes, with the label app, it is metered like any sandbox, and you can run commands in it (glac sandboxes exec).
When an instance sleeps
Only three things keep an instance awake:
- requests it is answering (an open HTTP/2 stream, such as a gRPC call, is a request until it ends);
- API calls that use it, such as a command run in it;
- holds that its own programs raise (below).
CPU use, packets, open connections and timers do not keep it awake. After the last of them ends it waits a while and sleeps. How long is picked from the app’s own traffic: where requests come closer together than a sleep and a wake are worth, it stays awake through the gaps; where they are far apart, it sleeps as soon as it has answered. scale.sleep_after_ms is the most it waits (three seconds unless you say, up to 600 000; 0 sleeps at once, always). Until the app has had a few requests, and while an instance has a WebSocket open, it waits the whole sleep_after_ms if you set one, or 100 ms if you did not. Work it does after answering is paused until the next request wakes it. A WebSocket stays open while the instance sleeps, and new data on it wakes it.
Work after the response
A handler that has more to do after its response (like ctx.waitUntil() on other platforms) raises a hold on the Unix socket /run/sbx/awake in the instance before it answers, and lowers it when the work is done. The instance waits, as after a request, and then stops. How to raise a hold, with code, is on sleep and wake.
scale.sleep_hold_max_mscaps how long holds keep an instance awake after its time idle has run out: 30 000 ms unless you say, up to 900 000;0ignores holds.scale.sleep_notice_mshas its programs toldsleep <ms>that long before it stops (none unless you say, up to 60 000).- While held, the instance is metered as awake.
When an instance is deleted
An instance that nothing has kept awake for scale.delete_after_ms is deleted: one hour unless you say less, from a second up. The next request makes a new one from the template, in milliseconds. A deleted instance keeps nothing, so a service that must keep data uses a Drive, or keyed instances, which are kept.
How many
| Setting | What it does |
|---|---|
scale.min_instances |
Instances kept awake in each region, requests or none (0 unless you say). They are metered as awake. |
scale.max_instances |
The most instances in a region. Without it, the plan’s number for an app that says none (below). |
scale.concurrency |
The most requests one instance has in hand at once, 1 to 1 000. Without it, an instance is full when its CPU or memory is, and the platform starts another. A service that handles one request at a time should say 1. |
glac cube update api --min-instances 1 --max-instances 20 --concurrency 50 --sleep-after-ms 2000These hold at once and make no version. Past the plan’s numbers a deploy or an update is refused (403 plan_cap_reached, param app_instances):
| Gratuit | Payant | |
|---|---|---|
Instances d’une application par région : sans max_instances / au plus |
2 / 5 | 50 / 500 |
| Instances éveillées en même temps | 5 | 500 |
| Leurs vCPU au total | 10 | 500 |
| Leur mémoire au total | 10 GiB | 1 000 GiB |
The awake instances, vCPUs and memory are counted for the whole account, with its sandboxes. An app in several regions shares what the account has left between them: each region’s share follows how many instances it had awake lately, and a region that needs more than its share is given what the other regions do not use within seconds (meanwhile its requests go to the app’s machines in another region). The limits are quotas, not reservations: when the machines of a region are full, a new instance can be refused even within them.
Where they run
An app runs in the regions it names (regions: na, eu, ap; all three unless you say). A request is answered in the region it comes in at, by a machine that serves the app there; another region takes it only when no machine there can. min_instances and max_instances count in each region. See regions.
Size
size is {vcpus, memory_bytes}: at least 1 vCPU and 128 MiB, the memory an even number of MiB (a whole number of the 2 MiB pages a machine’s memory is loaded in; another is refused, 400 invalid_field), and at most the plan’s largest instance (2 vCPU et 4 GiB on Free, 8 vCPU et 16 GiB on Paid). Without it, 2 vCPU et 4 GiB. On the command line, --vcpus 4 --memory-bytes 8GiB. The size is part of the version: changing it deploys a new one.