Volume 8 · Chapter 5 — High Availability, Disaster Recovery and Safe Change

Safe Deployment Strategies

Goutham Mayaluri 8 min read AWSCloudHigh AvailabilityDisaster Recovery

5.1 Introduction

Most outages are caused not by hardware failure but by changes - deployments that introduce bugs or break things. So a huge part of reliability is deploying changes safely: releasing new versions in a way that limits risk, catches problems early, and provides a fast way back. This chapter covers the deployment strategies - rolling, blue-green, canary - and feature flags, all of which let you ship changes with minimal risk of taking the system down. It’s a core reliability and interview topic because how you deploy is as important as what you deploy.

5.2 Why Deployment Strategy Matters

The blunt truth is that change is the leading cause of outages - a deployment introduces a bug, a bad config, or an incompatibility, and the system breaks. A naive deployment (replace everything at once with the new version) means if the new version is broken, the whole system is broken immediately, and recovering requires noticing and redeploying the old version under pressure. Safe deployment strategies exist to limit the blast radius of a bad change and to make recovery fast: expose the new version gradually or alongside the old, watch for problems, and roll back quickly if something’s wrong. The goal is that a bad deploy affects few or no users and is reversed in moments, rather than causing a full outage.

5.3 Rolling, Blue-Green, and Canary

Three strategies address this. A rolling deployment gradually replaces old instances with new ones a few at a time, health-checking each, so the service stays available throughout and a failure can halt the rollout - the default for orchestrators like Kubernetes. Blue-green runs two full environments - blue (current) and green (new) - deploying the new version to green, testing it, then switching all traffic from blue to green at once; if anything’s wrong, you switch back to blue instantly, giving a very fast rollback, at the cost of running two environments. Canary releases the new version to a small subset of users or traffic first, watches its metrics, and only proceeds to full rollout if it’s healthy - catching problems while they affect only a few users. Each limits risk differently: rolling by increment and health-gating, blue-green by instant switch and rollback, canary by exposing few users first.

flowchart TB
  subgraph Canary[Canary]
      C1[Route 5% to new version] --> C2{Metrics healthy?}
      C2 -->|Yes| C3[Ramp to 100%]
      C2 -->|No| C4[Roll back - only 5% affected]
  end
  subgraph BG[Blue-Green]
      B1[Blue = current serving]
      B2[Green = new, tested]
      B1 -->|switch traffic| B2
      B2 -.instant rollback.-> B1
  end

5.4 Feature Flags

Feature flags decouple deploying code from releasing functionality. A new feature is deployed behind a flag that’s off, so the code is in production but inactive; you then turn it on - for everyone, or for a small percentage first, or for specific users - independently of deployment, and you can turn it off instantly if it misbehaves. This is powerful for safety: you can release a feature gradually and disable it in seconds without a redeploy if there’s a problem, and you can test in production with a limited audience. Feature flags complement deployment strategies - the deployment safely gets the code out, and the flag controls when and to whom the feature is actually active, giving fine-grained control and an instant off-switch separate from the deploy pipeline.

5.5 Rollback and Health-Gating

Common to all safe deployment is the ability to roll back fast and to gate on health. Because container images and artifacts are immutable and versioned, rolling back is simply redeploying the previous known-good version - and the strategies make this quick (blue-green’s instant switch, canary’s abort, a rolling deployment’s halt). Health-gating - proceeding only if the new version passes health checks and its metrics look good - is what catches problems automatically before they spread; this is exactly why correct readiness/health checks matter so much (as seen with Kubernetes). The safety comes from combining a strategy that limits exposure with automatic health-gating and a fast, reliable rollback path, so a bad change is caught early and reversed with minimal impact.

5.6 Banking Production Scenario

A bank deploys changes to its services using canary releases gated on health: a new version first takes a small percentage of traffic while its error rate and latency are watched, and only ramps to full rollout if healthy - so a bad change affects a tiny fraction of customers and is automatically rolled back if metrics degrade. For some services it uses blue-green so it can switch traffic to a fully-tested new environment and instantly switch back if needed. Risky features are deployed behind feature flags, released gradually and disabled in seconds if they misbehave, without a redeploy. Because images are versioned and immutable, rollback is always fast. Combined with health-gating and observability, this lets the bank deploy frequently while keeping the risk of any change causing an outage very low - turning change, the leading cause of outages, into a controlled, reversible process.

5.7 Troubleshooting: Deployment Risk

Deployment-related outages point to missing safe-deployment practice. A bad deploy taking down the whole system at once means all-at-once replacement with no gradual exposure - use canary or rolling with health-gating. A broken release affecting all users before anyone noticed means no canary and no health-gating - release to a small subset first and gate on metrics. Slow or risky rollback means no fast rollback path - use blue-green’s instant switch or ensure the previous version can be redeployed immediately. A feature causing problems that can’t be turned off without a redeploy means no feature flag - put risky features behind flags. Downtime during deploys means no rolling/health-gated approach. The discipline is to limit blast radius (canary/rolling/blue- green), gate on health, keep rollback fast via immutable versioned artifacts, and use feature flags for fine-grained, instantly-reversible control.

Interview Question

How do you deploy changes safely, and what are the differences between rolling, blue-green, and canary?

I deploy changes safely because change is the leading cause of outages - a deployment introduces a bug, bad config, or incompatibility and the system breaks - so the goal is to limit the blast radius of a bad change, catch problems early, and have a fast way back, rather than replacing everything at once and hoping. A naive all-at-once deployment means a broken new version breaks the whole system immediately and recovery requires noticing and redeploying under pressure; safe strategies avoid that. The three main strategies differ in how they limit risk. A rolling deployment gradually replaces old instances with new ones a few at a time, health-checking each new instance before continuing, so the service stays available throughout and the rollout can halt if an instance fails - it’s the default for orchestrators like Kubernetes and gives incremental, health-gated replacement with no downtime. Blue-green runs two full environments, blue (the current version) and green (the new version): you deploy and test the new version on green, then switch all traffic from blue to green at once, and if anything is wrong you switch straight back to blue - so it gives a very fast, clean rollback (just flip traffic back), at the cost of running two full environments. Canary releases the new version to a small subset of users or a small percentage of traffic first, watches its metrics - error rate, latency - and only proceeds to full rollout if it’s healthy, so a problem is caught while it affects only a few users and is rolled back before wide impact. So rolling limits risk by incremental health-gated replacement, blue-green by an instant switch with instant rollback, and canary by exposing only a small audience first and gating on metrics. I complement these with feature flags, which decouple deploying code from releasing functionality: a feature ships behind an off flag, and I turn it on gradually - or for specific users - independently of deployment, and can turn it off in seconds if it misbehaves without any redeploy. Common to all of it is fast rollback and health-gating: because images and artifacts are immutable and versioned, rolling back is just redeploying the previous known-good version, and proceeding only when the new version passes health checks and looks healthy is what automatically catches problems before they spread - which is why correct health/readiness checks matter so much. So I deploy safely by choosing a strategy that limits exposure - canary or rolling for gradual health-gated rollout, blue-green for instant switch-and-rollback - gating on health and metrics, keeping rollback fast through immutable versioned artifacts, and using feature flags for fine-grained, instantly reversible control. That turns deployment, the leading cause of outages, into a controlled, low-risk, reversible process, which is what lets a bank deploy frequently without risking downtime on every change.

Chapter Revision Notes

  • Change is the leading cause of outages; safe deployment limits blast radius, catches problems early, and enables fast rollback.
  • Rolling: replace instances gradually with health checks (no downtime); blue-green: switch traffic between two full environments (instant rollback); canary: expose a small subset first, gate on metrics.
  • Feature flags decouple deploy from release - turn features on/off (or for a subset) instantly without redeploying.
  • Immutable versioned artifacts make rollback simply redeploying the previous known-good version.
  • Safety = limit exposure + health-gate + fast rollback + feature flags for fine-grained reversible control.