Skip to content

Blue Green Deployment

Overview

Blue/Green Deployment is a release strategy that reduces downtime and risk by running two identical production environments:

  • Blue: the currently live (active) version
  • Green: the new version ready to go live

You switch traffic from Blue to Green once you're confident the Green version is stable.

Advantages

  • Zero-downtime deployments: Users experience no interruption.
  • Rollback is easy: Just redirect traffic back to Blue.
  • Safer testing: Green can be fully tested in a production-like environment before being made live.
  • Canary-style verification: Some traffic can be directed to Green to monitor real performance.

Drawbacks

  • Infrastructure cost: Running two production environments (Blue & Green) can double costs temporarily.
  • Complexity: Needs good CI/CD, routing, and monitoring setup.
  • Stateful apps can complicate things: E.g., database schema changes may not be reversible or compatible between Blue and Green.

How It Works (Conceptually)

  1. You deploy the new version to the Green environment.
  2. Run automated and manual tests against Green.
  3. When confident, switch traffic (DNS, load balancer, or feature flag) from Blue to Green.
  4. Monitor for issues.
  5. If things go wrong, roll back by switching traffic back to Blue.

Example in Azure (Simplified)

Using Azure App Service:

  • Deploy Blue and Green as slots: production (Blue) and staging (Green).
  • Deploy new code to the staging slot.
  • Test it.
  • Swap staging and production slots.
// Example pseudo-code for Azure slot swap using Azure SDK
var appServiceClient = new WebSiteManagementClient(...);
await appServiceClient.WebApps.SwapSlotWithProductionAsync(
    resourceGroupName: "my-rg",
    name: "my-app-service",
    slotSwapRequest: new CsmSlotEntity { TargetSlot = "staging" }
);

Blue/Green vs Other Deployment Methods

Strategy Downtime Rollback Simplicity Risk Level
Blue/Green ✅ None ✅ Easy 🔽 Low
In-place ❌ Possible ❌ Manual revert 🔼 High
Canary ✅ None ⚠️ Medium 🔽 Low
Rolling ⚠️ Minimal ⚠️ Medium 🔽 Low

When to Use It

  • Mission-critical systems
  • You want minimal risk and quick rollback
  • Your infrastructure supports dual environments
  • You have automated tests and monitoring in place

Summary

  • Blue/Green = two identical environments (one live, one staged)
  • Switch traffic only after verifying the new version
  • Useful for zero-downtime, low-risk releases
  • Can be done in Azure using deployment slots or traffic managers