Repository navigation
docs(cloudflare): dedicated gradual deployments guide - #981
Conversation
Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
… rollouts Co-Authored-By: Claude Fable 5 <[email protected]>
…ersion typedoc Co-Authored-By: Claude Fable 5 <[email protected]>
…ers guides Co-Authored-By: Claude Fable 5 <[email protected]>
|
Install the packages built from this commit: alchemy bun add alchemy@https://pkg.ing/alchemy/dd0d459@alchemy.run/better-auth bun add @alchemy.run/better-auth@https://pkg.ing/@alchemy.run/better-auth/dd0d459@alchemy.run/pr-package bun add @alchemy.run/pr-package@https://pkg.ing/@alchemy.run/pr-package/dd0d459 |
ericclemmons
left a comment
There was a problem hiding this comment.
Absolutely no blockers, this is great!
Only clarifying questions that AI can probably fix up.
This is a confusing topic with several gotchas, but this is a very, very good addition for Alchemy and closes a parity gap with wrangler.
|
|
||
| const preview = yield* Cloudflare.Worker("Api", { | ||
| main: "./src/api.ts", | ||
| version: { parent, message: `PR #${process.env.PR_NUMBER}` }, |
There was a problem hiding this comment.
Can this be omitted for preview deployments entirely?
The current behavior for preview deployments is to be their own stage, right?
I'm just wanting to understand when I'd do a "normal preview deploy" (with no traffic) vs. a "preview deploy with a parent".
There was a problem hiding this comment.
Right — a plain preview stage needs no version at all and stays the default workflow. Added a "Preview version or preview stage?" section: a stage is fully independent infrastructure (own script, own copies of every resource), while a preview version rides the parent's script, settings, and version history without adding scripts to the account. Rule of thumb in the guide: stage for infrastructure changes, version for cheap shareable code previews.
| - uses: actions/checkout@v4 | ||
| - run: bun alchemy deploy | ||
| env: | ||
| API_TRAFFIC: ${{ inputs.traffic }} |
There was a problem hiding this comment.
This is a fantastic use-case and directly matches the need for health-mediated deployments.
| main: "./src/api.ts", | ||
| version: { | ||
| traffic: 10, | ||
| message: "new search index", |
There was a problem hiding this comment.
Message is optional, right? May be worth calling out what message is used for and how it appears. (This is just what we see in the dashboard, right? Usually it's a commit message, but in this case it's overridden here)
There was a problem hiding this comment.
Yes — message is optional. It is the human-readable note shown next to the version in the Cloudflare dashboard and wrangler versions list (a commit message is the usual choice); tag is its machine-readable sibling. The example now shows both as comments: message: "new search index" and tag: process.env.GITHUB_SHA, and the tag round-trips at runtime through the version metadata binding.
| the prop (or set `traffic: 100`) to promote the version to all | ||
| traffic. | ||
|
|
||
| The very first deploy of a script always goes to 100%, since there is |
There was a problem hiding this comment.
Very good default of 100%. This is actually a gotcha with wrangler versions upload - you'll get an error unless you deploy 1st!
| the majority holder **v1** at 80%. **v2** drops out of routing | ||
| entirely. | ||
|
|
||
| The abandoned version still exists as an upload, but it receives no |
| ```typescript | ||
| const api = yield* Cloudflare.Worker("Api", { | ||
| main: "./src/api.ts", | ||
| version: { traffic: 1 }, |
There was a problem hiding this comment.
This would be 1%, right? Because not setting version would be 100% of the new version. What would 0% do? Only respond to my curl requests (like the preview examples)?
I'm thinking of this example being a manual deploy or HMD for smoke testing.
API_PERCENTAGE=1 alchemy deploy
# outputs versionId
curl -s https://api.example.com/health \
-H 'Cloudflare-Workers-Version-Overrides: my-api="<versionId>"'
# OK
API_PERCENTAGE=50 alchemy deploy
curl -s https://api.example.com/health \
-H 'Cloudflare-Workers-Version-Overrides: my-api="<versionId>"'
# UNHEALTHY
alchemy rollback # or whatever the guidance would be. Setting it to 0%?There was a problem hiding this comment.
Yes, exactly 1% — and your flow works as written. traffic: 0 is upload-only: the version never enters the deployment, so an override header cannot reach it (overrides only resolve versions in the current deployment); it is reachable only at its preview URL. traffic: 1 is the smallest override-addressable deployment. The guide now says this inline in the smoke-test snippet, and the abort guidance is: re-deploy the last good ref at the default 100 — the bad version drops out of the deployment entirely.
| ``` | ||
|
|
||
| On a zone you control, a | ||
| [Transform Rule](https://developers.cloudflare.com/rules/transform/request-header-modification/) |
There was a problem hiding this comment.
Is there an Alchemy equivalent of this? For gradual deploys, "sticky deploys" and "version affinity" is a tricky technical topic for a lot of users.
Being able to easily say, "oh yeah, and sticky by cookie/claim, or fallback to sticky IP" would really complete this story.
There was a problem hiding this comment.
No sugar yet, but the guide now shows the alchemy-native way: a Cloudflare.Ruleset.Ruleset transform rule in the same Stack that sets Cloudflare-Workers-Version-Key from a session cookie (any stable property works — cookie, claim, tenant id). Caveat included: transform rules only see zone traffic, so bare workers.dev clients send the header themselves. First-class version: { affinity: { cookie: "..." } } sugar that provisions the rule automatically is spun off as a follow-up.
| ); | ||
| ``` | ||
|
|
||
| Set `version.tag` at deploy time (a git SHA is the usual choice) and |
There was a problem hiding this comment.
Really good usage of VersionMetadata() 👏
| `crossVersionCache: true` to share cached responses across versions | ||
| during a rollout. | ||
|
|
||
| ## Containers roll out by instance, not by request |
There was a problem hiding this comment.
May be worth a similar callback for things like Workflows, logpush, Durable Object migrations, etc.
These need to basically be deployed in a backwards/forwards-compatible way:
- Deploy the new service (e.g. Workflow) or new handler in a DO.
- Gradually rollout the worker that uses the new call paths while the old version continues calling the current paths.
- Once at 100%, you can safely remove the old call paths.
There was a problem hiding this comment.
Added to "What a version carries": DOs, Workflows, and service bindings sit outside the version, so both versions call them during the rollout — ship those changes expand-and-contract (new path at 100% first, ramp the caller, remove the old path after promotion), and keep KV/D1/DO schema changes compatible with both versions until the rollout completes.
- explain what version.message/tag are for and where they appear - preview version vs preview stage decision guidance - clarify traffic:1 vs traffic:0 for smoke tests + abort guidance - alchemy-native version affinity via Ruleset transform rule - expand-and-contract recipe for DOs/Workflows/service bindings Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
Add a dedicated guide for Worker versions & gradual rollouts at
/cloudflare/compute/gradual-deployments, covering theversionprop shipped in #948 plus the surrounding platform workflow from Cloudflare's gradual deployments docs:version: { traffic: N }), ramping, promotion, rollbackversion.parent+Worker.refCloudflare-Workers-Version-Overrides(using theversionIdoutput)Cloudflare-Workers-Version-Keyversion_metadatabinding andversion.tagcrossVersionCache)Also registers the guide in the Compute sidebar and cross-links it from the Workers page.
🤖 Generated with Claude Code