CodePark/ questions / Deployment & CI/CD
START PRACTICINGPRACTICE
Backend question · System design & architecture › Deployment & CI/CD

Compare blue-green and canary deployments. When would you choose each?

Blue-green switches all traffic to the new version at once. Canary moves traffic over slowly while you watch metrics.

In a blue-green deployment, you run two full production environments. Blue serves traffic. You deploy and test the new version on green. Then you switch the router so all traffic goes to green.

  • To roll back, you just switch back.
  • It needs double capacity during the switch.
  • The switch sends every user to the new version at the same moment.

A canary release sends a small share of traffic to the new version, for example 1%, then 5%, then 25%. You watch error rates and latency at each step. You send more traffic only if the metrics stay healthy.

  • Problems affect only a few users. The "blast radius" (how many users a bug can hurt) stays small.
  • Bad metrics can trigger an automatic rollback.
  • It needs good metrics and routing.
  • Both versions run side by side for longer.

Choose blue-green for fast, simple, all-or-nothing switches with instant rollback. Choose canary for high-traffic services, when you want real production evidence before every user gets the new version.

Both need database changes that work with the old and the new version.

  • Blue-green uses two environments and switches all traffic at once.
  • Blue-green gives instant rollback but needs double capacity.
  • Canary moves traffic over in small steps, and each step depends on healthy metrics.
  • Canary limits how many users a bug can hurt, but needs good observability.
  • Both need database schema changes that work with the old and new versions.