Skip to content

Commit 25ebcf4

Browse files
dobracmlejva
andauthored
Add snapshots vs templates comparison (#132)
Co-authored-by: Vasek Mlejnsky <vasek@e2b.dev>
1 parent c3927bf commit 25ebcf4

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

docs/sandbox/snapshots.mdx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,24 @@ from e2b import Sandbox
165165
Sandbox.delete_snapshot(snapshot.snapshot_id)
166166
```
167167
</CodeGroup>
168+
169+
## Snapshots vs. Templates
170+
171+
Both snapshots and [templates](/docs/template/quickstart) create reusable starting points for sandboxes, but they solve different problems.
172+
173+
| | Templates | Snapshots |
174+
|---|---|---|
175+
| Defined by | Declarative code (Template builder) | Capturing a running sandbox |
176+
| Reproducibility | Same definition produces the same sandbox every time | Captures whatever state exists at that moment |
177+
| Best for | Repeatable base environments | Checkpointing, rollback, forking runtime state |
178+
179+
Use templates when every sandbox should start from an identical, known state — pre-installed tools, fixed configurations, consistent environments.
180+
Use snapshots when you need to capture or fork live runtime state that depends on what happened during execution.
181+
182+
## Use cases
183+
184+
- **Checkpointing agent work** — an AI agent has loaded data and produced partial results in memory. Snapshot it so you can resume or fork from that point later.
185+
- **Rollback points** — snapshot before a risky or expensive operation (running untrusted code, applying a migration, refactoring a web app). If it fails, rollback - spawn a fresh sandbox from the snapshot before the operation happened.
186+
- **Forking workflows** — spawn multiple sandboxes from the same snapshot to explore different approaches in parallel.
187+
- **Cached sandboxes** — avoid repeating expensive setup by snapshotting a sandbox that has already loaded a large dataset or started a long-running process.
188+
- **Sharing state** — one user or agent configures an environment interactively, snapshots it, and others start from that exact state.

0 commit comments

Comments
 (0)