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
- Traffic goes to the blue environment — the current live version.
- The new build is deployed to the green environment — a copy of the blue one: the same configuration, the same capacity.
- The green environment is checked: smoke tests, cache warming, metric monitoring under test traffic.
- A router or load balancer moves all traffic to the green environment — users switch over without interruption.
- If problems arise, traffic is switched back to the blue environment — the rollback takes seconds.
- Once the new version proves stable, the blue environment is torn down or kept for the next build.
| Criterion | Traditional deployment | Blue-green |
|---|---|---|
| Downtime during release | yes: the version is replaced in place | no: the environments are switched |
| Rollback | re-releasing the old version | switching traffic back, takes seconds |
| Testing the new version | already on users | before traffic is switched, on the live environment |
| Resources | one environment | two — 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 pagesVerified 9 Nov