IICTPIICTP

Blog / Delivery & Agile / Platform Engineering & CI/CD

Platform Engineering & CI/CDNovember 20, 20265 MIN READ

Blue-green vs canary deployments: which should you use?

Blue-green deployment runs two full environments and switches all traffic from the old one to the new one at once, with a fast switch back if something breaks. Canary deployment sends a small share of traffic to the new version first and widens it only if the version behaves well. Blue-green gives the fastest rollback; canary limits how many users a bad release can reach.

In this post
  1. How does blue-green work?
  2. How does a canary release work?
  3. What about rolling deployments?
  4. What makes all of these harder?
  5. Which should you choose?
  6. Sources and further reading

How does blue-green work?

The live environment, say blue, serves users while green is deployed and tested. Traffic then moves to green in one step, usually at the load balancer or router. Blue stays running, so rolling back is the same switch in reverse. The cost is running two production environments, at least for a while.

How does a canary release work?

The new version gets a small slice of traffic, such as one server or a small percentage of requests. You compare its error rate, latency and business signals with the old version. If it holds up, the slice grows in steps; if not, traffic goes back to the old version and only that slice was affected.

What about rolling deployments?

A rolling deployment replaces instances a few at a time, which is the default in many platforms, including Kubernetes Deployments. It needs no extra environment, but for a while old and new versions serve users together and rollback means rolling again.

What makes all of these harder?

The database. During any of these strategies, old and new code may run against the same data, so schema changes must work with both. See zero-downtime database migrations. Long-lived connections, caches and background jobs also need a plan.

Which should you choose?

Use canary when you have good monitoring and enough traffic for a small slice to tell you something. Use blue-green when you need a clean, instant rollback and can afford two environments. Feature flags complement both, because they separate releasing a feature from deploying the code.

Sources and further reading

  1. Humble, J. and Farley, D. Continuous Delivery. Addison-Wesley, 2010.
  2. Fowler, M. BlueGreenDeployment. martinfowler.com.
  3. Beyer, B. et al. (eds.) The Site Reliability Workbook. O’Reilly, 2018. Chapter: Canarying Releases.

Go deeper: ADP™ credential · the TPBOK™ standard · Check your experience

IICTP is an independent technical credentialing body.

Keep reading

← All posts

Where do you stand?

Find the credential that fits the work you do.