SECTION 03 / 9

Part 2 — Deployment Strategies

3 min read
On this page 4 headings

Section point: Deployment strategies are ways of pushing code from the staging environment to the production environment. The lecture covers three: Blue/Green, Canary and Versioned deployment.

2.1 Blue/Green deployment (Staged deployment)

Idea: create a new, separate production environment for the new version, without affecting the current one.

How it works:

  • The Blue environment is the current live production environment. A router sends all users to it.
  • The new version is deployed to a second, identical production environment called Green. No users are sent there yet.
  • Green is tested thoroughly (integration testing and other testing).
  • The router switches all incoming requests from Blue to Green. Green is now live, and Blue sits idle.
Before the switch: the router sends 100% of live traffic to BLUE (Version 1). GREEN (Version 2) has been deployed, tested and verified but receives no live traffic yet.
Before the switch: the router sends 100% of live traffic to BLUE (Version 1). GREEN (Version 2) has been deployed, tested and verified but receives no live traffic yet.
Open image ↗
Illustration: Part 2 — Deployment Strategies
After the switch: the router now sends 100% of live traffic to GREEN (Version 2), which is monitored, while BLUE (Version 1) is kept on standby as a rollback option.
After the switch: the router now sends 100% of live traffic to GREEN (Version 2), which is monitored, while BLUE (Version 1) is kept on standby as a rollback option.
Open image ↗
Illustration: Part 2 — Deployment Strategies

Main advantage — easy rollback. If something goes wrong after the switch (errors, or the system crashes), the router simply sends users back to Blue, which is known to work.

Rollback: an issue is found in GREEN (Version 2), so the router sends 100% of traffic back to BLUE (Version 1) while the team investigates Green.
Rollback: an issue is found in GREEN (Version 2), so the router sends 100% of traffic back to BLUE (Version 1) while the team investigates Green.
Open image ↗
Illustration: Part 2 — Deployment Strategies

Regular cycling. The two environments take turns. If Green is live now, the next update is pushed from staging to Blue, and then the router switches to Blue. Blue and Green keep alternating between “real (live)” and “previous version”.

2.2 Canary deployment (Phased rollout / Incremental rollout)

Idea: instead of sending all users to the new version at once, slowly roll out the change to a small subset of users first, and increase the share step by step.

The name comes from the “canary in a coal mine”: a small early warning before everyone is exposed.

Canary deployment: the traffic router sends 95% of users to the stable Version 1 and 5% to the canary Version 2, which the team monitors closely.
Canary deployment: the traffic router sends 95% of users to the stable Version 1 and 5% to the canary Version 2, which the team monitors closely.
Open image ↗
Illustration: Part 2 — Deployment Strategies

How are the users for the new version chosen? The lecture lists these options:

  • Randomly
  • By user profile or demographics
  • By region: if there are servers in different locations, roll out to one region first, check that it works properly there, then roll out to other regions incrementally.
Canary traffic increases gradually: 5% canary traffic first, then 25%, then 100%, with performance checked before each step.
Canary traffic increases gradually: 5% canary traffic first, then 25%, then 100%, with performance checked before each step.
Open image ↗
Illustration: Part 2 — Deployment Strategies

Drawback: you must manage multiple instances at once. Some users are on the old version and some on the new one, so both have to be run and supported at the same time.

Blue/Green switches all traffic between two environments at once; Canary starts with a small portion of traffic (e.g. 5%) and gradually increases it while monitoring response time and error rate.
Blue/Green switches all traffic between two environments at once; Canary starts with a small portion of traffic (e.g. 5%) and gradually increases it while monitoring response time and error rate.
Open image ↗
Illustration: Part 2 — Deployment Strategies

2.3 Versioned deployment

Idea: allow users to choose which version to use, and keep all versions alive.

This is common in mobile apps (the lecture’s examples are Paytm and Instagram). You get a notification that an update is available:

  • if you update, you are routed to the new version;
  • if you don’t, you continue on the previous version.

Drawback: the company has to maintain multiple versions, because not all users update regularly. Companies therefore announce that only certain versions are supported up to a given date, after which older versions stop receiving support.

Versioned deployment: users choose; all versions kept alive
Versioned deployment: users choose; all versions kept alive
Open image ↗
Versioned deployment: users choose; all versions kept alive

Summary of Parts 1 and 2

TopicKey facts
DevelopmentDeveloper’s local machine, IDE, working copy, local DB; commit to mainline/master
TestingIntegration and system testing; on failure: remove code, find module, notify developer, roll back
Stagingpre-production; exact replica of production on a remote machine; release rehearsal, previews, performance/stress testing
ProductionLive environment used by all real users
Blue/GreenSeparate new production environment; router switch; easy rollback; environments cycle
CanaryPhased/incremental rollout to a subset (random, profile/demographics, region); drawback: multiple instances
VersionedUsers choose version; all versions alive; drawback: maintaining many versions
YOUR STUDY PROGRESS

Finished this section? Save your progress.

Back to top ↑