Skip to content
Web Development4 min read

Zero-Downtime Deployments: Blue-Green, Canary and Rolling Release Strategies

How to deploy without downtime: rolling, blue-green and canary releases, feature flags, health checks, expand and contract migrations, and rollback.

01

How do you deploy without downtime?

Run the new version alongside the old one, send traffic to it only when health checks pass, shift traffic gradually (rolling or canary) or all at once with an instant switch back (blue-green), keep database changes backwards compatible with an expand and contract approach, drain connections cleanly, and watch error rates and key journeys so you can roll back quickly. Feature flags then separate releasing features from deploying code.

This guide is for developers and engineering leads. It builds on DevOps for growing businesses and feature flag implementation.

02

Key takeaways

  • Readiness checks before traffic; graceful shutdown after.
  • Choose rolling, blue-green or canary per service and risk.
  • Database changes must work with old and new code.
  • Define automatic rollback triggers.
  • Keep APIs compatible with older clients.
03

Strategies compared

StrategyHow it worksGood forTrade-off
RollingReplace instances graduallyMost stateless servicesOld and new run together briefly
Blue-greenTwo environments; switch traffic at onceFast, clean rollbackDouble capacity during release
CanarySmall share of traffic first, then moreHigh-risk changes, large user basesNeeds good metrics and routing
Feature flagsDeploy dark, enable graduallySeparating release from deployFlag clean-up and testing
04

Mechanics that make it work

  • Readiness and liveness checks so traffic only reaches ready instances; see the Kubernetes Deployment documentation.
  • Graceful shutdown and connection draining so in-flight requests finish.
  • Stateless services with sessions in a shared store.
  • Backwards-compatible APIs and message formats during the overlap.
  • Automated smoke tests after each step.
  • Rollback triggers on error rate, latency and key business events.
05

Database migrations: expand and contract

Most downtime comes from schema changes. Expand first: add new columns or tables without breaking old code. Deploy code that works with both. Backfill data in batches. Switch reads to the new structure. Contract later: remove old columns once nothing uses them. Check that migrations do not take long locks on large tables, and test them on production-sized data. See database performance optimisation.

06

Blue-green and canary in practice

Blue-green suits services where a quick full switch and instant rollback matter, as described by Martin Fowler. Canary suits risky changes with enough traffic to detect problems early. For both, compare the new version's error rate, latency and business metrics, such as checkout completion, with the old version before going further. See monitoring and observability.

07

Hypothetical example: an ecommerce API

This example is hypothetical. An online retailer's deployments caused short outages and occasional failed checkouts. The team added readiness checks and graceful shutdown, moved to rolling deployments for most services and canary releases for the checkout API with automatic rollback on error rate, and adopted expand and contract for schema changes. A column rename that previously needed a maintenance window was done over three releases.

08

12 checks before updating a live web application

Zero-downtime techniques reduce risk; they do not remove it. Run through these checks before each production release. They will not guarantee a problem-free deployment, but they make problems easier to spot and quicker to undo. Scale the effort to the size of the change: a copy fix needs fewer checks than a schema migration.

CheckWhy it mattersHow to confirm
1. Tests pass on the exact build being deployedCatches regressions before users doCI run linked to the release
2. Change reviewed and scopedUnreviewed or bundled changes are harder to diagnoseApproved pull request; release notes
3. Database migrations are backward compatibleOld and new code run side by side during rolloutExpand-and-contract plan; tested on production-sized data
4. Configuration and secrets in placeMissing environment values break new featuresCompare environment settings with staging
5. Feature flags set as intendedLets you release code without exposing itFlag states documented for launch
6. Rollback path testedA rollback that has never been tried may not workPrevious version can be redeployed; data changes reversible or compatible
7. Backups recent and restorableLast line of defence for data changesRecent backup; restore tested
8. Dependencies and third-party changes knownProvider API or library changes can break productionCheck versions and provider changelogs
9. Monitoring and alerts readyYou need to see problems within minutesDashboards for errors, latency and key journeys
10. Timing and people availableReleasing before a weekend or sale is riskierSomeone who can fix or roll back is on hand
11. Smoke tests after deployConfirms critical journeys still workSign-in, checkout or lead form tested on production
12. CommunicationSupport and users are not surprisedSupport briefed; maintenance notice if anything is visible
09

Common mistakes

  • Readiness checks that always pass.
  • Schema changes that break the running version.
  • No rollback plan for data changes.
  • Canary releases without metrics to judge them.
  • Breaking API changes for older mobile app versions.
10
11

Conclusion

Zero-downtime deployment is a set of habits: health checks, graceful shutdown, gradual or switchable traffic, backwards-compatible data changes and quick rollback. Pick the strategy that matches each service's risk, measure releases, and use feature flags to separate deploy from release. To decide when to pause releases, see SLOs and error budgets.

Releases causing outages?

ZSpace Labs is an India-based, remote-first technology studio working with Australian and international businesses on web applications and release pipelines and mobile apps. If it would help to review how your software is released, we are happy to talk it through.

Start a Project
FAQ

Common questions.

Blue-green runs two full environments and switches all traffic from the old (blue) to the new (green) at once, keeping blue ready for rollback. Canary sends a small share of traffic to the new version first, watches metrics, then increases gradually.

Replacing instances of the old version with the new one a few at a time, keeping enough healthy instances to serve traffic. It is the default strategy for Kubernetes Deployments and many managed platforms.

Use expand and contract: first add new columns or tables in a backwards-compatible way, deploy code that writes to both or reads from the new structure, backfill data, then remove the old structure in a later release once nothing uses it. Avoid long locking operations during busy periods.

No, they complement them. Deployment strategies control which version of the code runs; feature flags control which features are active within it. Together they let you deploy often and release features gradually.

You cannot instantly roll back a mobile app on users' devices. Use staged rollouts in the stores, feature flags, and backend APIs that stay compatible with older app versions for a period.

Get in touch

Have a project in mind?

Whether you're building a new digital product, improving an existing website, or looking to automate part of your business — let's talk.