Running
Sleeping when idle (scale to zero)
Let an app stop after a while without requests and start again on the next one. It suits previews, staging and side projects.
Turning it on
The app's Settings (Sleep when idle), stackd apps sleep web 30 (off
to stop), sleep_after_minutes = 30 in a stackd.toml, or
PUT /api/apps/{id}/sleep {"sleep_after_minutes": 30}: 5 minutes to a
week. The app needs a domain, since a request to it is what wakes it.
It doesn't suit apps that must answer at once or take their own traffic
from elsewhere (queues, cron).
Asleep
An app goes to sleep once it has had no request and no deploy for its time, unless it's in maintenance or has a canary under way. All its replicas stop, its processes' included. Scheduled jobs still run (in containers of their own); their output doesn't wake it.
Waking
A request to an asleep app gets a "Starting up" page (503,
Retry-After: 3) that reloads every 3 seconds, whatever the WAF's mode,
and the app is deployed again as it was. Once a web replica is up, within
seconds the reloading page reaches the app. Waking takes as long as the
app takes to start: the images are still on the servers.
A wake that brings nothing up within 10 minutes goes back to asleep, for the next request to try again. Deploying an asleep app wakes it too; turning sleeping off wakes it.
Good to know
- Asleep apps aren't reported as down, and autoscaling leaves them alone.
- Uptime monitors on a sleeping app's domain wake it each time they check.
- Agents need v0.13.21 or later.