Blue-green deployment
Also called blue/green deployment.
A release method that runs two identical production environments and switches all traffic from the old one to the new one in one step.
Last updated
What it is.
Blue is the version live now. Green is the new version, deployed and tested alongside it with no user traffic. When green passes its checks, the load balancer or router sends all traffic to green. Blue stays running, so going back is one switch.
It differs from a canary release, which moves traffic over gradually. Blue-green is all at once, with a fast way back.
Why it matters
Releases are where most outages start. Blue-green makes a release a traffic switch rather than a change to running servers, which cuts downtime to near zero and turns rollback from a redeploy into seconds.
In a product build
We automate the switch in the CI/CD pipeline with health checks before and after. The hard part is the database: schema changes are written to work with both versions at once, so switching back does not break.
Common mistakes.
- 01
Making database changes that the old version cannot read, which kills the rollback.
- 02
Turning off blue straight after the switch, before the new version has proven itself.
- 03
Forgetting background jobs and scheduled tasks, which then run in both environments.
Related terms.
- Canary releaseA release method that sends a small share of users to a new version first, watches for problems, and widens the rollout step by step.
- CI/CD (continuous integration and delivery)An automated pipeline that builds and tests every code change (CI) and then releases it to users in a repeatable way (CD).
- Load balancerA service that spreads incoming traffic across several servers, and stops sending traffic to any that fail their health checks.
- Feature flagA switch in the code that turns a feature on or off for chosen users at runtime, without deploying new code.
- Infrastructure as code (IaC)Defining servers, networks, databases and other cloud resources in code files that are versioned and applied automatically, instead of setting them up by hand.
Guides and pages
Browse the full glossary or read answers to common questions.