Skip to content
syntaqx

Delivery, chapter 03 of 07

Deployment Strategies

Recreate, rolling, blue-green, canary and dark launches: how each one rolls back, what it costs, and why the database is usually the real constraint.

6 min readUpdated

Every deployment strategy answers one question: when the new version is wrong, how much damage does it do before you notice, and how fast can you undo it? They differ in how much traffic sees the new version, how long both versions run side by side, and what that safety costs in capacity. With continuous deployment, every merge goes through it.

Pick by the cost of a bad release. An internal tool can redeploy in place; a payment API needs to put a new version in front of a few percent of traffic and watch it before trusting it.

The Strategies#

Recreate

Stop the old version, start the new one. Kubernetes calls this Recreate: every old instance is terminated before any new one is created.

  • Rollback: recreate again with the old version, with the same downtime.
  • Costs: downtime on every deploy. No extra capacity, and old and new never run at once.
  • Use it when the versions genuinely can't coexist and a short outage is acceptable, like a batch worker between runs.

Rolling

Replace instances a few at a time. Kubernetes' default RollingUpdate keeps at most 25% of instances unavailable and creates at most 25% extra during the rollout (maxUnavailable and maxSurge), so capacity stays close to normal throughout.

  • Rollback: roll forward to the old version, which takes as long as the rollout did.
  • Costs: little extra capacity, but old and new versions serve traffic at the same time for the whole rollout. Every request might hit either one, so they must be compatible with each other and with the same database.
  • Blind spot: a rolling deploy has no built-in judgment. If the new version is bad, it keeps rolling until every instance is bad, unless something stops it.

Blue-Green

Run two full environments. Blue serves production; deploy the new version to green, test it there with production configuration, then switch traffic to green in one step. Martin Fowler's description is the classic one.

  • Rollback: switch traffic back to blue, still running. The fastest rollback of any strategy: just a routing change.
  • Costs: double capacity while both are up, and the switch is all-or-nothing. The new version gets 100% of traffic the moment it gets any.
  • The catch: both environments share data. Blue-green makes the code instantly reversible; it does nothing for a database migration that green already ran.

Canary

Send a small slice of traffic to the new version, compare it to the old, and expand only if it behaves: 1%, then 10%, then 50%, then everyone. Fowler's canary release is named for the bird that warned miners before the gas reached them.

NOTES: (UNLESS OTHERWISE SPECIFIED) 1 STAGES FROM THE CHAPTER; THE 30-MINUTE BAKE IS ILLUSTRATIVE: LONG ENOUGH FOR THE SLIS TO SEPARATE. 2 AT EACH GATE THE VERDICT COMPARES CANARY TO CONTROL AT THE SAME TIME, ON SLIS, AND ROLLS BACK BY ITSELF. 3 ROUTING THE SLICE BACK TO THE OLD VERSION: THE BAD RELEASE ONLY EVER REACHED THE CANARY'S SHARE. 4 EXPOSURE COUNTS MINUTES OF FULL TRAFFIC: EACH STAGE'S SHARE TIMES THE TIME IT SERVED, SUMMED. SHARES IN PERCENT OF TRAFFIC, TIME IN MIN. THE DRAWING CARRIES CODES; VALUES AND FORMULAS ARE IN THE TABLE. CONTROL CANARY NEW VERSION s1 s2 s3 s4 g1 g2 g3 2 B B B R1 PLAN VIEW · CANARY STAGES, RELEASE PASSES SCALE 1 MIN = 4 PX · 100% = 200 PX · BAKE TIME ILLUSTRATIVE 1 PLANNED, NEVER RUN CONTROL s4 s2 g2 ROLLED BACK 3 DETAIL A PLAN VIEW · RELEASE JUDGED BAD AT THE SECOND GATE SCALE 1 MIN = 4 PX · 100% = 100 PX s1 s2 B B X1 4 DETAIL A · EXPOSURE BEFORE THE SECOND GATE SCALE 10:1 VERTICAL · 10% = 100 PX VARIABLES · STAGES FROM THE CHAPTER CODE VARIABLE VALUE s1 canary share, stage 1 1% s2 canary share, stage 2 10% s3 canary share, stage 3 50% s4 everyone 100% B bake per stage, against control 30 min g1-g3 verdict gate after each bake automated R1 first canary to everyone 3 × B = 90 min X1 exposure, rolled back at g2 (s1 + s2) × B = 3.3 min Dimensional drawing of a canary release. Traffic to the new version steps from 1 to 10 to 50 percent, with an automated verdict gate after each stage and an illustrative 30-minute bake per stage, reaching everyone 90 minutes after the first canary. A second view shows a release judged bad at the second gate: it served 1 and then 10 percent of traffic before being routed back, an exposure of 3.3 minutes of full traffic, while the planned later stages never run. A detail view enlarges those two slices, whose areas sum to the exposure, and a table gives the shares, the bake, the rollout time and the exposure formula.
Each stage has to earn the next; a release that fails a gate has only ever reached the canary's share.
  • Rollback: route the slice back to the old version. A bad release only ever hurt the canary's share of traffic.
  • Costs: routing that can split traffic by percentage, monitoring that can tell the two populations apart, and time: a careful canary takes longer than a rollout.
  • Why it's the default for high-stakes services: it's the only strategy that limits blast radius and gives you a comparison. Not "are errors up?" but "are errors higher on the new version than the old one right now?", which cancels out everything else that changed at the same time.

Shadow and Dark Launches

Run the new code path on real traffic without users seeing its results. Dark launching calls new back-end behavior for existing users without them being able to tell; a shadow deployment sends a copy of real requests to the new version and discards its responses.

  • Use them for load and correctness on real traffic before launch: a rewritten service, a new database, a search index.
  • Costs: double the work for the shadowed traffic, and side effects must be impossible. A shadow that sends emails or charges cards isn't a shadow.

Feature Flags

Deploy the code everywhere, turned off, then release it to a percentage of users. Rollback is flipping the flag, for one feature, without reverting anything else. Feature Flags covers rollout and cleanup.

Comparing Them#

Strategy Blast radius of a bad release Rollback Extra capacity Old and new live together?
Recreate Everyone Redeploy, with downtime None No
Rolling Grows to everyone unless stopped Roll forward again Small Yes, throughout
Blue-green Everyone, instantly Switch back, seconds Double Briefly, at the switch
Canary The canary's share Shift the slice back Small to moderate Yes, deliberately
Feature flag Whoever the flag targets Flip the flag None Yes, in the same code

Let the Canary Be Judged Automatically#

A canary watched by a person at 2 a.m. is a canary nobody watches. The Google SRE workbook treats canarying as an A/B test between canary and control, and recommends:

  • Judge on SLIs, like error ratio and latency, because those map to what users feel. CPU and memory are noisy and rarely tell you a release is bad (see SLOs & Error Budgets).
  • Compare canary to control at the same time, not today to yesterday; time is its own source of noise.
  • Keep the metric set small, a dozen at most, and run one canary at a time so the signal isn't muddied.
  • Automate the verdict: if the canary diverges beyond a threshold, roll back without waiting for a human, and revisit thresholds as the service changes.

The Database Is the Real Constraint#

Every strategy except recreate runs old and new code against the same database at once. Code swaps in seconds; a schema can't. So whether a release is safe usually depends less on the strategy than on whether the schema change works with both versions. A renamed column breaks the old version mid-rollout, and rolling the code back doesn't un-rename it. With every change backward compatible through expand and contract, every strategy above can roll back. Without it, none can.

Immutable Deploys Make All of This Easier#

Every strategy above assumes "the old version" still exists, exactly as it was. With immutable artifacts it does: rolling back is pointing at the previous image, not reconstructing it. Serverless platforms take this furthest, since every deploy is a new, separately addressable build.

Versioning a Set of Services Together#

Everything above deploys one service at a time, and for independent services that's right. Some changes span several: a client, a server and three backend services that changed their contract on the same day. Each one rolling out on its own schedule produces combinations nobody tested. Riot's account of running its online services puts it bluntly: "Allowing unaligned streams of changes into a distributed system will eventually lead to preventable incidents," and its partner-operated shards, where operators assembled service versions themselves, had more incidents traced to microservice versions that weren't compatible with each other.

The fix is to version the set. Riot calls its unit an environment, a bundle of "all the declarative metadata required to fully specify, deploy, configure, run, and operate" a product's services, versioned as a whole and never changed in place:

{
  "environment": "prod-eu",
  "version": "2026.10.27-3",
  "services": {
    "accounts": { "image": "accounts@sha256:4c1d...e2", "replicas": 12 },
    "orders":   { "image": "orders@sha256:9a07...51",   "replicas": 20 },
    "billing":  { "image": "billing@sha256:b3f2...0c",  "replicas": 6 }
  },
  "config_overrides": ["base", "region/eu"]
}
  • Pin by digest, not tag. Kubernetes documents why: tags "can be moved to point to different images, but digests are fixed," so a set pinned by digest runs the same code every time it starts. A set of mutable tags is not a version.
  • One version per environment at a time. Rolling forward or back moves the whole set, and a hotfix to one service is a new set version, not a side-channel deploy. Two environments on the same version are known to be identical.
  • Layered overrides for what legitimately differs (region, credentials, scale) on top of the versioned base, so a deployment stays traceable to the set that was tested. Riot describes the same layering.
  • The set is still rolled out with the strategies above. A new set version can go to one region or shard first as a canary, with the previous set version kept ready to switch back to.

A release train is the same idea on a calendar: changes that are ready by a cut-off ship together on a fixed cadence, and anything that misses waits for the next one. Chrome ships a new milestone to stable every two weeks, and features that aren't complete by branch point "should be punted to the following milestone." Trains suit products where shipping is expensive per release (store-reviewed apps, game clients, appliances, on-premises software; see Mobile Releases). For backend services that can each deploy many times a day, keep services independently deployable with backward-compatible contracts (API Versioning), and reserve set versioning for the changes that genuinely have to move together.

References#

Reference

In practice