Skip to content

fix(orchestrator): limit concurrent template builds - #3836

Draft
luojiyin1987 wants to merge 3 commits into
e2b-dev:mainfrom
luojiyin1987:fix/template-build-concurrency-limit
Draft

luojiyin1987 wants to merge 3 commits into
e2b-dev:mainfrom
luojiyin1987:fix/template-build-concurrency-limit

Conversation

@luojiyin1987

@luojiyin1987 luojiyin1987 commented Nov 18, 2026 •

Copy link
Copy Markdown

Change

Template managers now run at most four template builds per node by default.
The max-concurrent-template-builds flag changes the limit for new requests.
Extra builds wait in the background while TemplateCreate returns.
Build deletion cancels a queued build.

Validation

  • go test -race ./pkg/template/server -count=1 passed (75 tests).
  • go test ./pkg/featureflags ./pkg/utils -count=1 passed.
  • git diff --check passed.

Open design points

The waiting queue has no size limit. Each accepted build holds a goroutine, cache entry, and work record.
Normal shutdown waits for running and queued builds. Its context has no deadline.
The new drain test confirms that Wait returns on a caller deadline while accepted builds continue.

Closes #3070.

@cla-bot

cla-bot Bot commented Nov 18, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have @luojiyin1987 on file. You can sign our CLA at https://e2b.dev/docs/cla . Once you've signed, post a comment here that says '@cla-bot check'

@luojiyin1987

Copy link
Copy Markdown
Author

@cla-bot check

@cla-bot cla-bot Bot added the cla-signed label Nov 18, 2026
@cla-bot

cla-bot Bot commented Nov 18, 2026

Copy link
Copy Markdown

The cla-bot has been summoned, and re-checked this pull request!

@luojiyin1987

Copy link
Copy Markdown
Author

This PR limits running builds. It does not limit accepted builds waiting for a slot.
Each waiting build holds a goroutine, cache entry, and work record.
Normal shutdown also waits for all accepted builds. Its context has no deadline.

Would you accept a pending admission limit as a follow-up issue?
If this PR needs the limit, which queue size and rejection status should it use?

This branch has not been deployed

No deployments
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.

Template builds are unbounded: TemplateCreate spawns one goroutine (and one FC VM + rootfs assembly) per request with no concurrency limit

1 participant