Canary Deployments

Canary Deployments

First of all, let’s try to understand what a deployment is. A deployment is a technique to upgrade or modify an application or service. The aim is to update the application from the user’s perspective without downtime. But this is said in theory because whenever we are deploying to production, things can go wrong. So the only possible way is to reduce the overall downtime, which can be achieved using canary deployments. The best part of using canary deployments is, it can be applied to mobile, desktop, and website applications.

Introduction to Canary Deployment:

It’s a technique of rolling out the releases of upgraded applications or services to a small subset of users, i.e., canaries, as an initial test. Before we jump in, it is worth spending time understanding, in brief, the history of canary deployment. It comes from the old British mining practice. They would send canaries in the coal mines to detect toxic gases (typically carbon monoxide) before they hurt humans. If something terrible happens to the canaries, then it’s a warning sign for miners, and miners would leave the mines. All this seems a little cruel and harsh.

Now comparing this with software deployments, a new feature is usually not released to a broader audience. The organization decides that the canary would receive 5% of the total traffic. If something goes wrong, only 5% of the users will be affected. It is about deploying an application in small, incremental steps (e.g., 1%, 5%, 10%,25%,50%, etc.), and only to a small group of people. As the organization feels confident, they roll out the changes to the remaining users or increment canaries’ size to a stage when the canary size reaches 100%.

Implementing Canary Deployment:

It’s straightforward to understand the canary deployment technique. We would need two clones of the production environment, having a load balancer in front of them, which will send all traffic. When we deploy an upgrade of the application or service, we want 5% of the users to use the new version and the remaining 95% to use the old (stable) version. If the 5% reports no errors, it can be rolled to more users, say 20%, 50%, etc., until everyone uses the new version. If the 5% has problems, then we can roll back, and 95% of the users will never be aware of this problem.

Benefits of using Canary Deployment:

  • Honest Feedback: It allows an organization to get invaluable input from real users about their application.
  • Zero Downtime: You can easily switch the traffic or change canaries’ size; hence it doesn’t generate downtime.
  • Easy rollback: If something goes wrong, an organization can easily roll back to the previous version.
  • Perform A/B tests: An organization presents two alternatives to the users; we can see which gets a better reception, helping us with A/B testing.

Leave a Reply