Take a snapshot
In this example, the snapshot is of a small app whose dependencies are installed and whose server is already running, with data loaded into memory.1
Prepare a sandbox
Start a sandbox and do all the slow work you want to save your future sandboxes from: install, build, load data,
start servers.
curl: install and start the app
Response
Response
response
2
Take the snapshot
Response
Response
response
-.3
Start sandboxes from it
Now create sandboxes from the snapshot. Each one is a new, separate sandbox with its own ID, address and files,
but it starts exactly as the snapshot was. This example creates three at once, one for each of three users:
Every new sandbox reports the same
curl: the server is already up
Response
Response
response
stdout holds the server’s answer, which looks like this:stdout
bootedAt time, which is the moment the snapshot’s server started. None of
them ran npm install, started the server or built the catalog. They all began with that work already done.What a new sandbox gets
A sandbox created from a snapshot shares some things with the snapshot and has others of its own:When you create a sandbox from a snapshot, you can only set
lifetime_sec, idle_timeout_sec and labels.
Everything else comes from the snapshot. If you send another setting, the request is refused with
400 snapshot_fields_fixed.Where snapshots fit
Snapshots help wherever many sandboxes need the same starting point:- A workspace per user. Keep one snapshot with your stack. Each user’s sandbox is created from it, and is ready the moment they sign in.
- Agents in parallel. Keep one snapshot with the repository cloned and dependencies installed, and create one sandbox per task.
- Evals and reinforcement learning. Every episode gets a fresh, identical environment, with nothing left over from the previous one.
- Code interpreters. Keep a Python process with pandas and your libraries already imported, so the user’s first piece of code runs at once.
List and delete
You can list your snapshots, with what each one stores, and delete the ones you no longer need:- Deleting the sandbox you took a snapshot of does not delete the snapshot. The snapshot is kept separately.
- A snapshot cannot be deleted while sandboxes created from it still exist. Delete those sandboxes first.
- A snapshot is kept until you delete it. It does not expire.
What it costs
A snapshot is stored, so it counts towards your account’s storage for as long as you keep it. Every account includes 20 GB of storage, shared by your snapshots and your sleeping sandboxes, and storage beyond that costs $0.10 per GB per month. See pricing. Each snapshot tells you what it stores and what that size costs:size_bytes: how much it stores, files, memory and running programs together.monthly_cost_usd: what that size costs a month at the storage price. Your included 20 GB come first, so while your storage stays under it, you pay nothing for it.
Good to know
A few more details:Errors
These are the errors you may see when working with snapshots. A snapshot of avm sandbox is also refused while a
command is still running in it, so wait for its commands to finish first.
Related
Images and builds
Where a sandbox starts on day one: a registry image or one built from a Dockerfile.
Sleep and wake
The same memory-keeping that makes snapshots work.