Video in progress
What is the difference between blue-green and canary deploys, and which one exposes fewer users to a bug?
In blue-green, the new version is brought up in full alongside the old one and traffic switches over all at once, and rolling back is instant too. In canary, a small share of traffic (say 5%) goes to the new version, and if the metrics look good, it is gradually increased.
📖 Answer
Blue-green. Two environments: "blue" is the current prod, "green" is the new version. You check green, then point the LB or DNS at it. If a problem shows up, you switch back to blue. Rollback is simple and fast. But if something goes wrong during the switch, it hits 100% of users, and you need double the resources.
Canary. The new version goes to a small share first:
5% -> watch for 15 minutes (errors, p99, business metrics)
25% -> 15 minutes
100%
If the new version has a bug, only 5% of users see it, and the rollback is automatic. In Kubernetes this is done with Argo Rollouts or Flagger, or with weighted routing in the ingress.
Both share one trap — the database. The old and new versions work with the same DB at the same time. If the new version drops a column, the old version (including the one you roll back to) crashes. So migrations have to be backward compatible: first add the column, make the code work with both, and remove the old column in the next release.
To make a canary meaningful, you need to break metrics down by version, otherwise the errors in that 5% disappear in the overall graph.
Sign up to mark studied questions and save your progress.