What You’ll Learn
- Uploading a volume once and reusing it across many sandbox creates
- Avoiding per-sandbox upload bandwidth and time cost
- Verifying each sandbox sees a private-but-identical copy under the mount path
Prerequisites
Why Volumes for Fan-out
Without volumes, every new sandbox repeats the upload: eachsbx.files.write() or sbx.files.put_raw() call pushes bytes from the SDK, through sandbox-manager, into that specific sandbox’s overlay. If you run 20 sandboxes over the same 500 MiB dataset you pay for 10 GB of ingress.
With volumes, the 500 MiB blob lives in object storage. Each Sandbox.create(volumes=[...]) hydrates it from there, directly, in parallel.
Code Walkthrough
What’s Happening Under the Hood
Volumes.createstreams the tarball into Declaw’s object store under an owner-scoped key. The SDK doesn’t retain any state about the payload past the returnedvolume_id.- Each
Sandbox.createhands the orchestrator aVolumeAttachmentlist. After the VM boots (warm-pool or cold), the orchestrator streams the blob back from object storage, unpacks it directly into the VM’s overlay via the in-VM file API, then acknowledges the create. - Sandboxes are isolated — a write to
/data/fooin sandbox A does not appear in sandbox B. The volume itself is read-only at hydrate time.
Tips
- The same
volume_idcan be attached concurrently from many processes; there is no lock or contention. - Multi-GiB uploads should use
request_timeoutonVolumes.createand on the client-side HTTPS call — a 3 GiB upload over a 25 MB/s pipe is ~2 minutes, and Python’s defaulthttpxtimeout is 30 seconds. - If a hydrate fails for any reason (object-store outage, tar corruption), the sandbox still boots and reports healthy; the files simply won’t be present. Check
/dataexistence before running logic that depends on it.
Phase 1 Limits
- Phase 1 volumes are read-at-boot. There is no write-back channel — if a sandbox edits a file under
mount_paththose changes die with the sandbox.