Course contentsShow
← Software Engineering
Lesson 709 of 1,93322. Continuous Delivery and DeploymentFree lesson

Blue-Green Deployment

Maintain two identical production environments and switch traffic between them for zero-downtime deployments.

Blue-Green Deployment

What you'll learn: How to deploy new versions with zero downtime by switching traffic between two identical production environments.


The Core Idea

Blue-Green deployment is a release strategy where you maintain two identical production environments — call them "Blue" and "Green." At any time, one environment (say, Blue) serves all live traffic while the other (Green) is idle. When you deploy a new version, you deploy it to the idle environment, test it thoroughly, then instantly switch traffic from Blue to Green. If something goes wrong, you simply switch back.

Think of it like having two identical stages at a theater. While the audience watches a performance on Stage Blue, you set up the new production on Stage Green. Once everything is ready and verified, you simply redirect the audience to Stage Green. The transition is instant, and if the new show has problems, you can immediately send everyone back to Stage Blue.

How It Works

  1. Blue is live — serving production traffic
  2. Deploy new version to Green — idle environment
  3. Test Green thoroughly — smoke tests, validation
  4. Switch traffic from Blue to Green — typically via load balancer or router configuration
  5. Monitor Green — ensure everything works
  6. Keep Blue as rollback — in case you need to revert

The switch itself is nearly instantaneous — often just updating a DNS record or load balancer configuration — resulting in zero downtime for users.

Benefits

  • Zero downtime during deployments
  • Instant rollback if issues arise
  • Full production testing before going live
  • Reduced deployment risk

The main trade-off is infrastructure cost — you need double the production capacity.

Key Takeaway: Blue-Green deployment eliminates downtime by maintaining two identical production environments and instantly switching traffic between them, with easy rollback if needed.