Course contentsShow
← Computer Science
Lesson 2392 of 2,87253. Agile and Software ProcessFree lesson

Deployment Strategies: Blue-Green and Canary

Techniques for zero-downtime deployments including running parallel environments and gradual traffic shifting.

Deployment Strategies: Blue-Green and Canary

You'll learn: two powerful techniques—Blue-Green and Canary deployments—that enable zero-downtime releases by safely routing traffic to new versions of your application.

The Problem: Risky Deployments

Traditional deployments often mean downtime, rollback headaches, or users suddenly hitting buggy code. What if you could deploy fearlessly, knowing you can instantly revert or gradually test changes with real traffic?

Blue-Green Deployment

Imagine two identical production environments: Blue (current live version) and Green (new version).

How it works:

  1. Blue serves all user traffic
  2. Deploy your new code to Green
  3. Test Green thoroughly in isolation
  4. Switch the router/load balancer to point at Green
  5. Blue becomes your instant rollback option

The benefit: Near-instant cutover and rollback. If Green has issues, flip the switch back to Blue in seconds.

Analogy: Like having two stages at a theater. While the audience watches Blue stage, you set up the entire next act on Green stage, then rotate the audience's view when ready.

Canary Deployment

Named after "canary in a coal mine," this strategy gradually shifts traffic to the new version.

How it works:

  1. Deploy new version alongside the old
  2. Route a small percentage (e.g., 5%) of users to the new version
  3. Monitor metrics, errors, performance
  4. Gradually increase traffic: 10% → 25% → 50% → 100%
  5. Roll back instantly if problems arise

The benefit: Real-world validation with limited blast radius. If the canary "dies" (shows errors), only a fraction of users are affected.

Analogy: Testing a new bridge by having a few brave volunteers cross first, then increasing foot traffic as confidence grows.

Choosing Your Strategy

Blue-Green: Best when you need all-or-nothing deployment with instant rollback.
Canary: Best when you want gradual risk mitigation and real-world validation.

Key Takeaway: Both Blue-Green and Canary deployments enable zero-downtime releases by intelligently managing traffic between old and new application versions, giving you confidence and control during deployment.