Bookmarks

Blue-green deployment

A release technique in which two identical environments — “blue” and “green” — run side by side, and traffic is switched from the old version to the new one in a single move.

Also: blue/green deployment, blue-green switching, blue-green

checked 9 Nov

All terms

The idea is to keep two production environments side by side: one serves users while the new version is deployed to the other. It is tested on the green environment, and then a router or load balancer switches all traffic to it in a single move — no downtime, and just as simple a rollback if something goes wrong.

Where the term comes from

The technique had been used before, but Martin Fowler described blue-green deployment in his blog on 1 March 2010. By his account, the name was coined by some combination of Daniel Terhorst-North and Jez Humble.

How the switch happens

  1. Traffic goes to the blue environment — the current live version.
  2. The new build is deployed to the green environment — a copy of the blue one: the same configuration, the same capacity.
  3. The green environment is checked: smoke tests, cache warming, metric monitoring under test traffic.
  4. A router or load balancer moves all traffic to the green environment — users switch over without interruption.
  5. If problems arise, traffic is switched back to the blue environment — the rollback takes seconds.
  6. Once the new version proves stable, the blue environment is torn down or kept for the next build.
CriterionTraditional deploymentBlue-green
Downtime during releaseyes: the version is replaced in placeno: the environments are switched
Rollbackre-releasing the old versionswitching traffic back, takes seconds
Testing the new versionalready on usersbefore traffic is switched, on the live environment
Resourcesone environmenttwo — for the duration of the release

Cost and limitations

Blue-green requires double capacity for the duration of a release: two sets of servers or containers, while the database, queues and external integrations are shared between them. Because of the shared database, schema changes are made compatible with both the old and the new version of the application: the new part is added first, and the old one is removed only after the switch. In-flight requests and background jobs are given time to finish after the switch, and “sticky” sessions are best avoided — otherwise some users stay on the old environment.

How it differs from a canary release

Blue-green moves all users to the new version at once — the risk goes to everyone or no one. A canary release mixes the new version into a small share of traffic and ramps it up gradually, comparing the metrics of the two versions. A rolling update gets by with a single environment altogether: instances are replaced in batches, but the old and new versions work side by side for a while.

Sources

the term is written from these pages

Verified 9 Nov

Not to be confused with

what it is mixed up with and how it differs

  • canary release

    A canary release moves part of the traffic to the new version and ramps it up based on metrics, while blue-green switches all traffic at once.

  • rolling update

    A rolling update replaces the instances of a single environment in batches, while blue-green keeps two full environments and switches all traffic in one go.

In depth in the references

where the topic is covered in detail