Lifecycle
A lifecycle is the set of states a sandbox passes through between its creation and its deletion, together with the moves between them. Each state keeps a different part of the sandbox, from running processes down to nothing at all. Moves happen on request or automatically, such as after a period without use. A sandbox is in exactly one state at any time.
Each state trades cost against how quickly the sandbox can run again. A running sandbox holds processors and memory, while a stopped one holds only its disk and costs far less while it waits. Platforms that charge by usage reflect this in price, billing a running sandbox for compute and a stopped one only for storage. Moving between states is how a user, or the platform, keeps that bill in check.
The control plane records which state each sandbox is in and drives it from one to the next. Platforms name and split the states differently, but most have something close to the same set. Each move can fail partway, so the control plane must be able to retry it or roll it back. Clients usually watch the state of a sandbox to know when it is ready.
Sandbox states
Sandbox states are the conditions a sandbox can be in, told apart by what still runs and what is kept. Pausing and stopping are the two common ways to leave the running state without deleting anything. They differ in what happens to memory, which decides how fast the sandbox can come back. Either can be undone with a start or a resume, unlike a delete.
Pausing keeps memory, either frozen in place on the host or written out as a memory snapshot. Resuming brings back the running processes exactly where they were, with their state in memory intact. A paused sandbox still holds its memory somewhere, so it costs more to keep than a stopped one. Network connections may still break during a long pause, because the other side times out.
Stopping is like shutting down a computer. Files on disk survive, but processes end and must start again from the beginning, so the next start is slower than a resume. In exchange, a stopped sandbox frees all of the memory it held on its host. That makes stopping the usual choice for a sandbox that will sit idle for long.
| State | What runs | What is kept |
|---|---|---|
| Creating | Nothing yet. | The request, while a host is chosen and the image is prepared. |
| Running | Processes. | Memory, disk and a network address. |
| Paused | Nothing, because processes are frozen. | Memory and disk, often on the same host. |
| Stopped | Nothing. | Disk only, because memory is lost. |
| Archived | Nothing. | Disk, moved to object storage. |
| Deleted | Nothing. | Nothing. |
| Error | Nothing reliable. | Whatever was there when a create, start or stop failed, often still recoverable. |
Archiving
Archiving is the move of a stopped sandbox's disk off its host to cheaper storage. The disk goes from the host's local disk to object storage, which frees space on the host. Nothing changes from the point of view of the user, since every file is kept. The host can then use the freed space for sandboxes that are running.
Starting an archived sandbox first has to copy its disk back. That copy adds to the start time, so archiving suits sandboxes that are unlikely to run again soon. The copy takes longer the larger the disk, so big sandboxes feel it most. Some platforms fetch data lazily on start, loading blocks as they are read rather than all at once.
An archived sandbox costs little while it waits, since object storage is cheap. Deleting it removes even that cost, and nothing of the sandbox can come back afterwards. Object storage is also more durable than the disk of a single host, so an archived sandbox survives the loss of the host it ran on. That durability makes archiving a sound place for work that may be needed months later.
Idle timeouts
An idle timeout is a limit that acts on a sandbox automatically after a period without activity, stopping, pausing or deleting it as configured. It exists because sandboxes are often left running after their work ends, by a crashed client or a person who walked away. Without one, a forgotten sandbox keeps holding processors and memory until someone notices. Across a large fleet, forgotten machines can make up a real share of the bill.
A second, longer timeout may archive or delete the sandbox later. Setting the timeouts is a choice between paying for idle machines and making users wait for the next start. Interactive work favors longer timeouts, since a person may pause for minutes between commands. Batch tasks that finish and exit can use short ones.
What counts as activity varies between platforms. Incoming requests and open sessions usually count, while running processes count only on some platforms, so a sandbox busy with a background job may still be stopped or deleted. Long jobs therefore often report activity on purpose or turn the timeout off. A timeout that is too eager stops work midway, while one that is too lax wastes money.