DevOpsGitHub

Continuous Deployment: Blue-Green and Canary

TT
TopicTrick Team
Continuous Deployment: Blue-Green and Canary

Continuous Deployment: Blue-Green and Canary


1. Blue-Green Deployment: The "Light Switch"

  • The Setup: You have two identical server environments: Blue (The old site) and Green (The new site).
  • The Move: You deploy the new code to Green. You test it privately. If it works, you flip a switch at the Load Balancer (Module 182).
  • The Rollback: If the new site crashes, you flip the switch back to Blue in $0.01$ seconds.
  • Result: The users never see a "Maintenance" page. They just see the new site appear instantly.

2. Canary Releases: The "Slow Reveal"

Named after canaries in a coal mine.

  • You deploy the new code to only 1% of users.
  • You watch the Observability dashboard (Module 190). If the "Error Rate" stays at 0, you move to $10%, 50%$, and finally 100%.
  • This is how Facebook tests new features. They test them on a tiny group of people before giving them to the whole world.

3. Feature Flags: Decoupling Deploy from Release

In 2026, we don't "Deploy code to turn on a feature."

  • We deploy the code HIDDEN behind a Feature Flag (a simple If statement).
  • if (user.has_new_header) { show_new_ui() }.
  • A marketing manager can "Turn on" the feature by clicking a button in a dashboard, without a single line of code being moved.

4. Automating with GitHub Actions

In your CD workflow:

  1. Wait for CI: Ensure all tests passed (Module 202).
  2. Environment Approval: Add a "gate" where a human must click "Approve" before the code moves from Staging to Production.
  3. Deployment: Use Cloud-specific actions (like aws-actions/configure-aws-credentials) to move the bits.

Frequently Asked Questions

Which is better: Blue-Green or Canary?

  • Blue-Green: Better for "Small" sites or apps where a 1% bug is still too risk. It's simpler to set up.
  • Canary: Better for "Massive" apps where you want to test how the server handles $1$ million users before giving it to $100$ million.

What about the Database? This is the hard part. Your database must support Both versions of the code at once (Backward Compatibility). You never delete a column until the migration is 100% finished. This is the mark of a Senior DevOps Engineer.


Key Takeaway

CD is the "Freedom to Ship." By mastering Blue-Green switches and the safety of Canary rolls, you gain the ability to deploy code on a Friday afternoon without any fear. You graduate from "Managing a dangerous release" to "Architecting a Constant Flow."

Read next: GitHub Actions: Secrets and Environments →


Part of the GitHub Mastery Course — engineering the release.