Skip to content

docs: clarify templates vs snapshots performance and many-template usage#250

Open
mintlify[bot] wants to merge 1 commit into
mainfrom
mintlify/578de46b
Open

docs: clarify templates vs snapshots performance and many-template usage#250
mintlify[bot] wants to merge 1 commit into
mainfrom
mintlify/578de46b

Conversation

@mintlify

@mintlify mintlify Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Adds guidance under sandbox snapshots explaining why templates are typically faster and more resource-efficient (compact memory after guest OS restart, more effective prefetching), and adds a "Creating many templates" section in the template quickstart covering per-customer/per-project usage at scale and layering templates with fromTemplate.

  • docs/sandbox/snapshots.mdx: new "Performance: prefer templates when possible" subsection under Snapshots vs. Templates.
  • docs/template/quickstart.mdx: new "Creating many templates" section with a fromTemplate example.

@cla-bot cla-bot Bot added the cla-signed label Jun 13, 2026
@mintlify

mintlify Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor Author

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
e2b 🟢 Ready View Preview Jun 13, 2026, 12:24 AM


## Creating many templates

There is no practical limit on how many templates you can have. It's perfectly fine to create **tens or hundreds of thousands of templates** — for example, one template per customer, per project, or per agent run.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like telling customers that there is no limit, while we plan to release pricing for this in the future, afaik.
Usually, when customers ask about it, I mention that pricing for total space used will be introduced, but there are no limits planned.

@mishushakov mishushakov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added comments

Use templates when every sandbox should start from an identical, known state — pre-installed tools, fixed configurations, consistent environments.
Use snapshots when you need to capture or fork live runtime state that depends on what happened during execution.

### Performance: prefer templates when possible

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to "Performance"

- **Compact memory.** During a template build, the guest OS is restarted before the long-running process is captured. Memory is compact and any setup-time processes that aren't needed at runtime are gone, so sandboxes start with less memory pressure and fewer resources.
- **More effective prefetching.** E2B optimistically prefetches data needed to start a sandbox. For templates this prefetching is highly effective; for snapshots its effectiveness is significantly lower due to memory fragmentation and general memory pressure from the captured live state.

If you can express the state you need as a declarative template build, you'll generally get faster cold starts and lower overhead than capturing the equivalent state as a snapshot. There is no limit that should discourage you from creating many templates — see [Creating many templates](/docs/template/quickstart#creating-many-templates) for using templates per-customer or per-project.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd soften this "There is no limit that should discourage you from creating many templates — see [Creating many templates]"

there will be possibly limits in the future?


## Creating many templates

There is no practical limit on how many templates you can have. It's perfectly fine to create **tens or hundreds of thousands of templates** — for example, one template per customer, per project, or per agent run.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this may change so I would not promise it 100%

The template name is the identifier that can be used to create a new Sandbox.
</Note>

## Creating many templates

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe rename to "Scaling templates" or something that makes it clear that you can have n of them with lower overhead


### Layering templates with `fromTemplate`

When you build many similar templates (e.g. a customer-specific template per customer that all share the same base setup), use [`fromTemplate`](/docs/sdk-reference/js-sdk/v2.29.1/template#fromtemplate) to start from an existing template instead of rebuilding the shared layers from scratch each time. This keeps per-customer builds fast and reuses the cached base.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use https://e2b.dev/docs/sdk-reference/js-sdk/latest/template#fromtemplate
it will point to the latest SDK version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants