
Module 6 Lesson 3: Blue-Green vs Canary Releases
Zero downtime mastery. Explore the advanced deployment patterns used by world-class engineering teams to ship code with zero interruptions to the user.
Module 6 Lesson 3: Blue-Green vs Canary Releases
For a small blog, 1 minute of "Down time" is fine. For a bank or a hospital, it's not. These two patterns ensure your app is always reachable.
1. Blue-Green Deployment
- Blue: The current live version.
- Green: The new version you just built.
- You build "Green" on a separate server.
- You run all tests on "Green."
- When you are ready, you "Flip the Switch" (at the Load Balancer) to send all traffic to Green.
- The Benefit: If Green is broken, you flip the switch back to Blue in 1 second. Zero users saw a "Site Down" page.
2. Canary Release
Named after the "Canary in a coal mine," this strategy is about Progressive Exposure.
- Deploy the new version (
v2) to just 1% of your users. - Watch the error logs.
- If everything is fine after 1 hour, increase it to 10%.
- By the end of the day, 100% of users are on
v2.
- The Benefit: If there is a massive bug, only 1% of users were affected. You "Save" 99% of your customers from the bug.
3. Rolling Updates (The Kubernetes Default)
If you have 10 servers, you update them one by one.
- Server 1 updates -> Server 2 updates -> ...
- There are always 9 servers online at any given moment.
4. Comparing the Strategies
| Strategy | Speed of Rollback | Infrastructure Cost | Risk |
|---|---|---|---|
| Simple Rebuild | Slow | Low | High |
| Blue-Green | Instant | High (2x Servers) | Low |
| Canary | Instant | Medium | Lowest |
Exercise: The Strategy Selector
- A social media app wants to launch a new "Like" button animation. Which strategy should they use?
- A government tax database is updating its core encryption logic. Which strategy should they use?
- In GitLab, how would you implement a "Canary" using Manual Jobs (Module 3) and 2 different deployment servers?
- Research: How does a Load Balancer (like Nginx) decide which user gets the "Canary" version vs the "Standard" version?
Summary
Advanced deployment isn't about "Getting the code there"; it's about Risk Management. By using Blue-Green or Canary patterns, you protect your company's reputation and your users' experience from the inevitable bugs that exist in every piece of software.
Next Lesson: Controlling the live site: Feature Flags (GitLab Unleash).