Skip to content

feat(apply): add --concurrency limit for deploy/destroy#504

Open
sam-goodwin wants to merge 1 commit into
mainfrom
claude/parallelism-deploy-destroy-EYZPn
Open

feat(apply): add --concurrency limit for deploy/destroy#504
sam-goodwin wants to merge 1 commit into
mainfrom
claude/parallelism-deploy-destroy-EYZPn

Conversation

@sam-goodwin

@sam-goodwin sam-goodwin commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Cap how many resources apply at once. Defaults to unbounded.

# no more than 64 resources mid-lifecycle at any time
alchemy deploy --concurrency 64
alchemy destroy --concurrency 64

# omit the flag → unbounded (every ready resource applies at once)
alchemy deploy

Programmatic:

yield* apply(plan, { concurrency: 64 });   // bounded
yield* apply(plan);                         // { concurrency: "unbounded" } (default)

The limit is a shared semaphore taken only around the provider call, never around the dependency wait — so a resource blocked on its upstreams holds no permit and a tight limit (even --concurrency 1) can't deadlock the DAG.

Bound how many resources run a provider lifecycle operation at once.
Defaults to unbounded; defers to Effect's concurrency model via a shared
semaphore that gates only the actual provider call, never the dependency
wait, so a tight limit can never deadlock the DAG.

- `apply(plan, { concurrency })` accepts `"unbounded" | number` (default
  `"unbounded"`). The limit is enforced at `instrumentLifecycle`, the single
  dispatch chokepoint, so it covers create/update/replace/precreate/delete
  across executePlan, converge, and collectGarbage with one shared permit.
- `--concurrency <n>` flag on `deploy` and `destroy` (e.g. `--concurrency 64`).
- Test harness `deploy`/`destroy` accept `ApplyOptions` so the limit is
  testable.
- apply.test.ts: unbounded runs all at once; a limit caps the high-water
  mark; concurrency 1 serializes; a dependency chain doesn't deadlock under a
  tight limit; destroy honors the limit.
@alchemy-version-bot

Copy link
Copy Markdown
Contributor

Install the packages built from this commit:

alchemy

bun add alchemy@https://pkg.ing/alchemy/a85fd1e

@alchemy.run/better-auth

bun add @alchemy.run/better-auth@https://pkg.ing/@alchemy.run/better-auth/a85fd1e

@alchemy.run/pr-package

bun add @alchemy.run/pr-package@https://pkg.ing/@alchemy.run/pr-package/a85fd1e

@alchemy-version-bot

Copy link
Copy Markdown
Contributor

Website Preview Deployed

URL: https://alchemyeffectwebsite-worker-pr-504-67p2sklcbinzz3cl.testing-2b2.workers.dev

Built from commit a85fd1e.


This comment updates automatically with each push.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants