SDSystem DesignConcepts to case studies
System DesignDSA
x
0/311
Part 1: Foundations
Part 2: APIs and Communication
Part 3: Caching
Part 4: Data and Storage
Part 5: Architecture
Part 6: Distributed Systems
Part 7: Advanced Data Topics
Part 8: Operations and Security
  • Deployment Strategies Overview
  • CI/CD Pipelines
  • Rolling Deployments
  • Blue-Green Deployments
  • Canary Releases
  • Feature Flags
  • A/B Testing Infrastructure
  • Schema Migrations
  • Rollbacks and Immutable Infrastructure
  • Multi-Region and Active-Active
  • Infrastructure as Code (Terraform)
  • Auto-Scaling Policies
  • Zero-Downtime Deployment
  • Chaos Engineering
  • Shadow Traffic and Dark Launches
Part 9: Estimation and Interview Method
Part 10: Case Studies
System Design/Operations and Security/Deployment Patterns

Deployment Strategies Overview

A map of the ways to put new code into production, and the risk each one carries.

⏱ 12 min readBeginnerMust KnowHas visualizer
SummaryConceptReal-Life ExampleWhy?Where?How It WorksStepsKey TermsPros & ConsMistakesReal WorldRead NextInterview Q&ACheat-Sheet

01Quick Summary

A deployment strategy is the plan for moving a new version of your software from "finished" to "running for real users", with as little pain as possible if something is wrong.

  • The simplest plan is to stop the old version and start the new one. It works, but users see downtime.
  • Better plans mix old and new for a while: rolling, blue-green and canary.
  • Each plan trades speed, cost and risk. The key question is: "if this release is bad, how many users are hurt, and how fast can we go back?"

02Concept: What is it?

Writing code is only half the job. The other half is releasing it. A release changes a running system that real people are using at that very moment, so it is one of the most common causes of outages.

A deployment strategy answers three questions. How do users keep being served while the change happens? Who sees the new version first? And how do we undo it if it goes wrong?

The four basic strategies
Recreate
πŸ›‘Stop v1
↓
▢️Start v2
Rolling
v2
v2
v1
v1
a few at a time
Blue-green
Blue v1
Green v2
switch all traffic
Canary
95% v1
5% v2
small slice first
They differ in how old and new versions share the traffic while the change is happening.
🧠Two ideas hide in every strategy
Blast radius is how many users a bad release can hurt. Rollback speed is how fast you can get back to the last good version. A good strategy keeps the first small and the second fast.

03Real-Life Example

🍡Changing the Menu at a Busy Restaurant
A restaurant wants to switch to a new menu. It could close for a day and reprint everything (recreate). It could change one table at a time while the rest keep the old menu (rolling). It could open a second dining room with the new menu, test it with staff, and then send every guest there at once (blue-green). Or it could hand the new menu to just a few tables and watch their reactions before giving it to everyone (canary).
Restaurant
Deployment
Closing for a day
Recreate: downtime, but simple
Changing a few tables at a time
Rolling update
A second, ready dining room
Blue-green: a full second environment
Sending guests to the new room
Switching the load balancer
A few tables try the new menu first
Canary release
Guests complain about the new menu
Error rate and latency rise
Going back to the old menu
Rollback
The life of a safe release
πŸ“¦Buildone package
→↓
🚚Releaseto a few first
→↓
πŸ‘€Watcherrors, speed
→↓
βœ…Continueor roll back

04Why Do We Need It?

πŸ•’No downtime
Users should not see a maintenance page every time you ship a fix.
🎯Small blast radius
If the release is bad, only a few users see it before you stop.
↩️Fast undo
A good plan makes going back as easy as going forward.
πŸš€Ship often
When releases are safe, teams release many times a day instead of once a quarter.
πŸ’ΈRight cost
A second full environment costs money. You pick how much safety you want to pay for.
😌Calmer teams
A boring, practised release process means no late-night panics.
Every release is a small experiment on live users. A deployment strategy decides how many users take part and how quickly you can stop.

05Where Do We Use It?

☸️Kubernetes
Deployments do rolling updates by default. Tools on top add blue-green and canary.
☁️Cloud platforms
Managed services (load balancers, app platforms, serverless) offer built-in traffic shifting.
πŸ”€Load balancers and gateways
They decide which version a request reaches, which makes canary and blue-green possible.
πŸ“±Mobile and desktop apps
App stores support staged rollouts: release to a growing percentage of users.
πŸ•ΈοΈService meshes
Split traffic between versions by weight, with no change to the app.
🏭Pipelines
A CI/CD pipeline runs the chosen strategy automatically on every release.

06Types / Parts / How It Works

The main strategies side by side

StrategyHow it worksDowntimeExtra costRollbackBest for
RecreateStop all old, start all newYes, a short outageNoneRedeploy the old version (slow)Dev and test, or apps that can not run two versions
RollingReplace servers in small batchesNoneSmall (maybe a surge server)Roll forward or reverse the roll (slowish)Most stateless services
Blue-greenRun old (blue) and new (green) side by side, then switchNoneHigh (a second full environment)Flip traffic back (very fast)Releases that must be safe and quick to undo
CanarySend a small share to the new version, then grow itNoneSmallSend the share back to 0% (fast)Risky changes, large user bases

Techniques that work together with the strategies

TechniqueWhat it adds
Feature flagsRelease the code without turning the feature on. Switch it on for some users later.
Shadow (mirror) trafficCopy real requests to the new version and ignore its answers, just to compare.
A/B testingShow different versions to different users to measure which one is better, not just safer.
Immutable infrastructureNever change a running server. Replace it with a new one built from a fresh image.
Automatic rollbackA tool watches error and latency numbers and goes back for you.
VisualizerRelease a good or a bad version four different waysSwitch between the four strategies with a good release, then a bad one. Make the bug worse and the detection slower, and watch how many requests fail and how long the rollback takes.
Strategy

Replace the servers a few at a time. The share of users on the new version grows steadily over 10 minutes.

The new release is...
Share of users on the new version, minute by minute (cyan = new version, red = service down, amber line = bug noticed)
0 min15 min30 min
Failed requests over 30 minutes, for every strategy (the selected one is highlighted)
Recreate100,800 failed
Rolling37,800 failed
Blue-green28,800 failed
Canary5,400 failed
Failed requests
37,800
in 30 min
Most users hit
70%
by the bug
Back to normal
14 min
rollback done
Extra servers
+25%
while releasing
By minute 6 about 70% of users were on the bad version, and the rollback is a slow reverse rolling update. 37,800 requests failed. Noticing sooner helps a lot.

A simplified model with a simulated clock and no random numbers. The extra-server and rollback numbers are illustrative, not measurements. Real values depend on your platform and your settings.

07How to Use It / Steps / Implementation

Choosing and running a strategy

  1. 1
    Build once
    Create one versioned, tested package (an image or an archive). Deploy the same package everywhere, so what you tested is what you ship.
  2. 2
    Pick by risk
    Low-risk change on stateless servers: rolling. High-risk or hard-to-undo change: canary or blue-green. A throwaway test environment: recreate is fine.
  3. 3
    Define healthy
    Write down the numbers that mean the release is fine: error rate, latency and a few business numbers such as checkouts per minute.
  4. 4
    Add readiness checks
    A new server should only receive traffic after it reports that it is ready. Without this, a rolling update can replace healthy servers with broken ones.
  5. 5
    Release in steps
    Go to a small share first. Wait long enough to see real traffic. Then grow the share if the numbers stay healthy.
  6. 6
    Plan the undo first
    Know before you start how to go back, and how long it takes. Practise it. Check that the database change can also go back or is safe for both versions.
  7. 7
    Automate
    Put the strategy in a pipeline so it runs the same way every time, with automatic stops when the numbers look bad.
πŸ’‘Old and new run together, so they must get along
In rolling, canary and blue-green, versions v1 and v2 run at the same time and often share one database. Make changes backward compatible: v2 must work with the old data shape, and v1 must survive the new one. See Schema Migrations.
⚠️Sticky users
If one user can bounce between v1 and v2 on every request, they may see the page flip back and forth. Use sticky routing (the same user always goes to the same version) when that matters.

08Key Terms to Know

TermMeaning in easy words
DeploymentPutting a version of the software onto the servers that run it
ReleaseMaking that version available to users (often the same moment, but not always)
DowntimeTime when users can not use the service
Blast radiusHow many users a bad change can hurt
RollbackGoing back to the last good version
Rolling updateReplacing servers in small batches
Blue-greenTwo full environments, with traffic switched from one to the other
CanarySending a small share of users to the new version first
Readiness checkA test that tells the load balancer a new server can take traffic
Traffic shiftingChanging what share of requests goes to each version
Backward compatibleA newer version that still works with data and callers made for the older one

09Pros, Cons and Trade-offs

βœ… Pros
  • Releases without a maintenance window
  • A bad release hurts fewer users
  • Rollback becomes a routine step
  • Teams can ship small changes often
  • Numbers, not hope, decide when to continue
⚠️ Cons
  • More moving parts than stop-and-start
  • Two versions run at once, so compatibility needs care
  • Blue-green needs a second environment
  • Canary needs good monitoring to be useful
  • Small traffic slices may be too few to spot rare errors

Trade-offs

ChoiceWe gainWe lose
RecreateSimplest, no mixed versionsDowntime, and the biggest blast radius
RollingNo downtime, low extra costSlow rollback, and two versions run for a while
Blue-greenInstant switch and instant rollbackDouble the servers while releasing
CanarySmallest blast radius, real-user proofSlower release, needs monitoring and traffic control
Faster rolloutLess time with mixed versionsLess time to notice problems
Slower rolloutMore time to watch the numbersLonger release, and more time in a mixed state

10Common Problems and Mistakes

Common mistakes

  1. No readiness check. A rolling update replaces healthy servers with broken ones and nobody stops it.
  2. Releasing a database change and code together. If you must go back, the old code can no longer read the new data.
  3. Not watching the numbers. A canary is only useful if someone (or something) looks at it.
  4. No rollback plan. The first time you try to go back should not be during an outage.
  5. Blue and green sharing state badly. Both sides write to one database, or each side has its own caches that are out of sync.
  6. Releasing on a Friday evening with nobody watching.
  7. Rebuilding the package per environment. What you tested is not what you ship.

Things to watch

🧩Mixed versions
Two versions share one database, one queue and one cache. Both must understand every message.
πŸ“‰Capacity during the update
Draining servers lowers capacity. At high traffic, the rest may be overloaded.
πŸ”ŒLong connections
WebSockets and long downloads need draining time, or they will be cut.
πŸ§ͺToo little canary traffic
At 1% of a quiet service, you may wait hours for enough requests.

11Real-World Examples

☸️Kubernetes Deployments
Rolling update is the default, with settings for how many servers can be unavailable or added during the update.
🧰Argo Rollouts and Flagger
Open-source tools that add canary and blue-green releases to Kubernetes, with automatic analysis and rollback.
☁️AWS CodeDeploy and Elastic Beanstalk
Offer in-place, rolling and blue-green style deployments for servers and containers.
πŸ§ͺLarge web companies
Many roll changes out to a small share of users and data centres first, and widen step by step.
πŸ“±App stores
Staged rollouts let a mobile release go to a growing percentage of users.
🐦Feature-flag platforms
Let teams turn a feature on for 1%, then 10%, then everyone, without a new deploy.
πŸ“Note
Product defaults and settings change between versions. Check the documentation of your platform before relying on a specific behaviour.
Mini case: a risky change with a canary
🐀5% canary5 minutes
→↓healthy
πŸ“ˆ25%5 minutes
→↓healthy
πŸš€100%done
Small test Growing Everyone
The pipeline watches the numbers and decides for you.

12Related Topics to Read Next

CI/CD Pipelines→

The pipeline is what runs a deployment strategy automatically.

Rolling Deployments→

A closer look at the most common strategy.

Blue-Green Deployments→

Two environments and an instant switch.

Canary Releases→

Release to a small slice of users first.

Feature Flags→

Separate deploying code from turning a feature on.

Rollbacks and Immutable Infrastructure→

How to go back quickly and safely.

13Interview Questions with Short Answers

14Quick Revision Cheat-Sheet

  • βœ”Goal: ship changes with no downtime, a small blast radius and a fast undo.
  • βœ”Recreate: stop old, start new. Simple, but has downtime.
  • βœ”Rolling: replace in batches. Cheap, slow to roll back.
  • βœ”Blue-green: two environments, flip traffic. Instant rollback, double cost.
  • βœ”Canary: small share first, grow if healthy. Smallest blast radius.
  • βœ”Always: readiness checks, health numbers defined up front, and a practised rollback.
  • βœ”Database: keep changes backward compatible, and release them in separate steps.
  • βœ”One line: β€œShow the new version to as few users as possible, for as short a time as possible, until the numbers say it is safe.”
← Previous
Data Governance and Feature Stores
Next β†’
CI/CD Pipelines