Expand description
Keeping a VM awake from outside while work runs inside it.
The platform measures idleness by inbound requests through the endpoint proxy. Work
inside the guest does not count: measured 2026-09-23 in us-east-1, a CPU-busy exec was
suspended between 60 and 70 seconds after the last inbound request under a 60-second
maxIdleDurationSeconds. Requests from inside the guest arrive over loopback and never
reach the meter. So the only keepalive is a caller outside the VM that keeps sending
requests, and KeepAwake is that caller: an unauthenticated GET /v1/health every
interval, optionally ending once the daemon stops reporting busy.
§Why the interval is capped at half the idle window
One missed poll must not suspend the VM. With the interval at most half the window, a
single failed or slow poll still leaves a second one inside the window. When the caller
does not know the VM’s window, the cap assumes the smallest window the platform accepts
(MIN_IDLE_DURATION_SEC), which is the only assumption that cannot be too generous.
§The probe is the caller’s
KeepAwake::run owns the policy (cadence, busy, deadline, error tolerance, stop)
and takes the poll as a closure. super::Session::keep_awake passes its own health
call. A binding holding a sandbox-owned session passes one that first checks, under the
sandbox’s lock, that the VM is still running and answers None when it is not: a
health poll against a VM the caller just suspended would auto-resume it, which is the
opposite of what a suspend asked for.
Structs§
- Keep
Awake - A keepalive’s policy. Build with
KeepAwake::new, check withKeepAwake::validate. - Keep
Awake Report - What a finished keepalive did.
- Keep
Awake Task - A keepalive running as a background task. Dropping it stops the task.
Enums§
- Keep
Awake End - Why a keepalive ended without an error.
Constants§
- DEFAULT_
KEEP_ AWAKE_ INTERVAL - The default cadence when the caller names none: a third of the window, at most this.
- DEFAULT_
TOLERATED_ ERRORS - Consecutive retryable poll failures tolerated before the keepalive gives up.
Type Aliases§
- Running
Gate - Whether the VM behind a keepalive is still one it may poll. See the module docs.