graphical user interface, application

Canary deployment is a deployment strategy that gradually rolls out a new version of an application to a small percentage of users. It allows you to test in production without exposing it to all of your users. If there are any problems with the new version, you can quickly roll it back without affecting most users.  

It's a continuous deployment technique used to test new features, updates, or changes on a small and controlled subset of users before gradually rolling it out to all end users. It minimizes the risks associated with new deployments and catches issues before they affect everyone.  

Canary deployments are critical because they can help reduce the risk of introducing new features or updates to your application. For example, let's say you are introducing a new feature to your website. You could use a canary deployment to roll out the new feature to 5% of your users. If the new feature is working well, you can gradually increase the percentage of users who are using the new feature. If there are any problems with the new feature, you can quickly roll it back to the previous version.  

The supported target types for canary deployment include: 

  • Virtual Machines (VMs) 
  • Containerized applications (using Docker or similar technologies) 
  • Serverless functions (like AWS Lambda or Google Cloud Functions) 
  • Microservices architecture 

Canary deployments help identify potential issues and dependencies. Plus, fix them before a full-scale rollout, thereby minimizing the impact of any problems. 

What is canary deployment?  

The name "canary deployment" comes from the old practice of using canaries in coal mines. Canaries are very sensitive to carbon monoxide, so they worked as an early warning system for miners. If the canary died, it was a sign that there was too much carbon monoxide in the air, and the miners needed to evacuate.  

In a similar vein, canary deployment mimics the idea of the canary in the coal mine. By initially deploying changes to a small subset of users, known as the "canary group," organizations can monitor how the new features or updates perform in a controlled environment. If any issues arise, they are contained within the canary group, allowing them to be quickly detected and addressed before impacting the broader user base.  

In software development, a canary deployment acts as an early warning system for problems with new code. By gradually rolling out the new code to a subset of users, you can monitor the new code and identify any downtime issues before they affect everyone. This incremental approach helps microservices providers reduce the risk and uncertainty around larger-scale software releases.  

How canary deployment works? 

A canary deployment workflow follows a step-by-step process to gradually roll out new features or updates to a small subset of users or servers. Here is how the process works: 

1. Duplicate infrastructure 

A separate environment is set up alongside the existing production infrastructure. It serves as the canary deployment environment. 

2. Feature flags 

They play a crucial role by allowing developers to enable or disable specific features. By using feature flags, organizations can control the visibility of new changes and turn them on or off. 

3. Group selection  

A small subset of users or servers form the canary group. This group typically represents a small percentage of the overall user base or servers. 

4. Load balancers  

Load balancers move traffic between the existing production environment and the canary deployment environment. Organizations can control the percentage of traffic directed to a group. 

5. Gradual rollout  

Initially, the new features or updates are rolled out to the canary group. The rest of the users or servers continue to use the existing production environment. 

6. Monitoring   

Gather feedback, track performance metrics, and detect any issues or discrepancies. Organizations closely monitor parameters such as response times, error rates, and user feedback to ensure the changes are functioning as intended. 

7. Gradual expansion 

Based on the feedback and analysis from the canary group, organizations can make informed decisions. If the changes perform well and meet the desired criteria, expand the deployment to a larger user base or additional servers. However, if issues arise, organizations can quickly roll back the changes, reverting to a stable production environment. 

8. Full release   

Once the canary deployment phase is deemed successful, organizations can proceed with a full release of the stable version in the deployment pipeline, having the changes to the entire user base or all servers. Alternatively, organizations may improve the changes based on the feedback and data gathered.

The role of CI and CD

Continuous Integration (CI) and Continuous Deployment (CD) often support the implementation of canary deployment. CI ensures frequent code integration and allows for early detection of integration bugs, making it easier to manage code for different versions of an application during canary deployment. 

CD automates the deployment process, ensuring fast, consistent, and reliable delivery of features. It aids in the quick release of new versions for canary testing, and if successful, facilitates the gradual rollout to all users. 

This is where a Customer Data Platform (CDP) can support you in consolidating customer data from various sources, allowing for seamless integration and deployment of customer-centric applications. 

It enables real-time testing and deployment of new features based on customer data insights, and ensures data consistency across different systems, reducing errors during integration and deployment. 

Furthermore, a CDP can provide feedback loops for monitoring application performance post-deployment, enabling rapid response to any issues. In fact, our latest experimentation report shows how companies with integrated CDP see up to 80% more expected impact with their experimentation efforts. 

Image showing impact of using a CDP

Image source: The Experimentation of Evolution 

Benefits of canary deployment  

Canary deployment offers several advantages and use cases:   

  • In rolling deployment, sending out specific changes to a small subset of users helps mitigate risks upfront. This approach limits the scope of potential issues and allows for early bug detection. Organizations can address problems before impacting the broader user base.  
  • Deploying changes to a limited audience enables organizations to gather feedback and detect bugs that may not be identified during testing ensuring zero downtime.  
  • By gradually rolling out changes, organizations can closely monitor the impact and performance of the changes. If issues arise, they can quickly roll back to the previous stable state or apply fixes to the canary group, minimizing disruption for the real user base.  
  • You get feedback from user usage and gather insights into how users interact with the new features or updates. Use this feedback to ensure the changes meet user expectations and improve user experience.    

A canary deployment strategy encourages a culture of continuous delivery and experimentation. By implementing feature flags and gradually rolling out changes, organizations have more flexibility to experiment with new ideas and gather data-driven insights. This iterative approach allows for faster iterations, quick feedback loops, and the ability to continuously improve the software. 

Implementing canary deployment 

Here are some practical steps for implementing canary deployment in an application or system: 

1. Choose the right approach  

Define a clear deployment strategy that specifies how canary releases will be deployed and monitored. There are different approaches, such as A/B testing, blue-green deployment, and red-black deployment. Choose the one that best suits your needs and requirements. 

2. Configure the deployment process  

Set up a separate canary version to deploy the new version of the application. It should closely resemble the production environment but with fewer users or traffic. Next, decide how much traffic to send to the new version, how to monitor the deployment, and how to roll back to the old version if necessary. 

3. Scale your infrastructure  

Gradually scale up the canary release based on monitoring and feedback, while closely monitoring key metrics and rollback strategies. Route a portion of live traffic to the Canary environment to test for issues or bugs. Gradually increase the percentage of users using the new version and scale your infrastructure to handle the increased load. 

4. Monitor the deployment  

Monitor the key performance metrics during the canary deployment to ensure the new version is stable and performs well. It is essential to ensure that the new version is performing as expected. 

Key metrics  

Here are key metrics to measure the impact of canary deployment:  

  • Error rate: This shows if the canary deployment introduces any increase in errors or failures.  
  • Latency: It describes the application's response time to ensure the canary deployment does not negatively impact performance.  
  • Conversion rate: It tracks if the canary deployment affects the user conversion rate or any specific business metrics.  
  • User feedback: It gathers user feedback to understand their experience and identify any issues or improvements needed.  

Canary deployment vs. others  

Canary deployment is a versatile deployment strategy for a variety of scenarios. It can be combined with other deployment strategies for enhanced functionality and flexibility. For example, you could roll out a new feature to selected users, and then use A/B testing to compare the performance of old and new features. 

Canary deployment is more gradual than A/B testing. In A/B testing, users are randomly assigned to different versions of an application, while in canary deployment, the new version is gradually rolled out to a small percentage of users. It can help to reduce the risk of introducing new problems into production. 

Canary deployment can be used to roll out new features or updates, while A/B testing is typically used to compare the performance of two versions of an application. While blue/green deployment is specifically designed for this purpose.

Here are some examples where a canary deployment template is more suitable:  

  • When you are deploying a new feature or update that could hurt users.  
  • When deploying a new version of an application that is not yet fully tested.
  • When you want to get feedback from users in real time migrate to a plan before you roll out the new release to everyone.

Canary deployment vs. Blue-green deployment 

Canary deployment and Blue-Green deployment are both built-in release strategies, but they differ in approach. Canary deployment gradually rolls out changes to a small subset of users before deploying it to the entire infrastructure. 

It allows potential issues to be spotted and addressed with minimal impact. On the other hand, Blue-Green deployment involves two identical production environments (Blue and Green). The new version is released in the green environment, while the blue environment runs the current live version. Once testing is completed in the green environment, the router is switched to make it live, minimizing downtime. 

Common considerations  

Here are some potential pitfalls when implementing canary deployment:  

  • It can introduce data inconsistencies between old and new versions of an application. It can happen if users are interacting with both versions of the application at the same time. To avoid this, you need to have a plan for ensuring data consistency.  
  • It is important to have a rollback strategy in case of problems with the new version. It will allow you to quickly roll back to the old version without impacting users. Use a version control system to track changes to your applications' configuration.  
  • Canary deployments can involve changes to the configuration of your application. Manage these changes and ensure that they are applied correctly.  

Overall, canary deployment is a complex deployment strategy that can be challenging to implement. However, it is a valuable method for reducing the risk of introducing new problems into production and improving the reliability of your software deployments.

Canary deployment and feature flags 

Canary deployment is a valuable method for improving the reliability of your software deployments. By gradually rolling out the new version, you can monitor it closely and identify issues before they affect everyone. 

If you belong to a DevOps team, use Optimizely's free feature flags to get started.  

If you're already using feature flags and want to go a step further, try feature management to take full control of your feature releases right now. 

About the author