Blue-Green Deployment
What is Blue-Green Deployment?
Blue-green deployment is a release technique that runs two identical production environments, deploys a new version to the idle one and switches traffic to it, allowing near-instant rollback if problems appear.
Updated November 2026 · 2 min read
Blue-green deployment is a way of releasing software with almost no downtime and an instant way back. A team runs two identical production environments, called blue and green. One is live and serves all traffic. The new version is deployed to the other, tested there and then traffic is switched over, usually at the load balancer or router. If problems appear, traffic is switched back to the previous environment, which is still running the old version.
The technique was described by Dan North and Jez Humble in the 2000s and popularized through Martin Fowler's 2010 article and Humble and Farley's book Continuous Delivery.
How blue-green deployment works
- Blue is live, serving all users.
- The new version is deployed to green, which receives no user traffic.
- Green is tested, often with smoke tests and automated checks against production data and services.
- The router switches all traffic from blue to green.
- Blue stays running for a while as a fallback.
- If green has problems, traffic switches back to blue. If not, blue becomes the target for the next release.
Blue-green vs. canary
| Blue-green | Canary | |
|---|---|---|
| Traffic switch | All at once | Gradual, starting with a small share |
| Rollback | Instant switch back | Stop and reduce traffic to the new version |
| Infrastructure cost | Two full environments, at least during the release | Smaller additional capacity |
| Exposure to a bad release | All users, briefly | A small share of users |
Some teams combine them, switching traffic from blue to green gradually.
How to handle databases in blue-green deployment
Switching application servers is easy. Databases are harder, because both versions usually share one database. Schema changes must work with both the old and new versions of the application. Teams handle this with the expand-and-contract pattern: first add new columns or tables without removing old ones, release the new application, then remove the old schema in a later release once rollback is no longer needed.
Blue-green deployment example
Consider a hypothetical airline whose booking system is updated in a monthly two-hour outage window at 2 a.m. It moves to blue-green deployment on its cloud infrastructure. Releases now happen during the day: the new version goes to green, automated checks run for 15 minutes and traffic switches over. On the third release, error rates rise after the switch, and the team switches back to blue within a minute. Customers see a brief rise in errors rather than a long outage, and the team fixes the problem and releases again that afternoon.
Common pitfalls
- Incompatible database changes that make switching back impossible.
- Environments drifting apart in configuration.
- Long-running sessions or jobs broken by the switch.
- Doubling infrastructure permanently when it could be scaled down between releases.
Blue-green deployment is one technique in continuous delivery and release management.
Frequently asked questions
What is the difference between blue-green and canary deployment?
Blue-green deployment switches all traffic from the old environment to the new one at once, with rollback by switching back. A canary deployment moves traffic gradually, starting with a small share of users, so fewer people see a bad release. Blue-green needs two full environments during a release, while canaries need less extra capacity. Some teams combine the two.
Why are databases the hardest part of blue-green deployment?
Both environments usually share one database, so schema changes must work with the old and new versions of the application at the same time. Teams use the expand-and-contract pattern: add new columns or tables without removing old ones, release the new version, then remove the old schema in a later release once rollback is no longer needed.
Does blue-green deployment double infrastructure costs?
Only temporarily, if it is managed well. Blue-green deployment requires two full production environments at least during a release, but the idle environment can often be scaled down between releases. Keeping both at full size permanently is a common pitfall, as is letting their configurations drift apart so the switch no longer behaves as tested.
Related terms
Canary Deployment
Releasing to a small share of users first, then expanding if it's healthy.
Continuous Delivery (CD)
Keeping software always releasable so any change can ship on demand.
Release Management
Planning and controlling how software changes reach production safely.
Behavior-Driven Development (BDD)
Agreeing behavior as plain-language examples that become tests.