Canary deployment: use cases, deployment strategies, and best practices | getunleash
Deploying a new feature all of a sudden is not secure for company owners or users. What can you do to avoid the risk?
One possible solution might be canary deployment. It’s an increasingly popular solution for companies that want fast and frequent updates. Companies like Google (Chrome), Mozilla, Firefox, and Netflix have used canary deployment. It’s also a well-known strategy in the open-source world.
But it’s not just for tech giants. Canary development works well for both small and large distribution systems. This article provides baseline knowledge for anyone interested in canary development:
- What it is
- How it works
- Advantages + disadvantages
- Implementation
- Best practices
What is canary deployment?
Canary deployment (also called a canary release) is a deployment pattern based on making small, staged releases. It allows you to test new changes or features to a subset of users or servers.
The new software version is implemented gradually. For example, you could start with 5% of users, then move on to 10%, and so on. The development team can use this to get instant feedback from users. This can cut down on the risk of losing customers.
How does it work?
In the context of software development and deployment, a canary is a small group of users or systems used to test a new version of software before it is deployed to the entire user base.
Canary deployment involves releasing a new version of the software to the canary group while the old version is still being used by the remaining users. This allows the canary version to be tested in a live production environment before being deployed to all users.
Initially, you probably want to validate the new implementation for a few of your internal testers. After validation, the next step would be to enable the new implementation for a handful of your internal users, e.g., all company employees. Then, the new implementation should be enabled gradually for a larger and more significant part of the user population.
Each iteration is supported by carefully considering the application’s key metrics, such as performance numbers and reported issues. If problems occur, the deployment can be stopped and the old version restored. However, if the canary deployment is successful, the new version can be gradually rolled out to the remaining users.
Steps in the deployment process
Implementing a canary deployment strategy may vary depending on a company’s specific needs. However, there are a few crucial steps for successful implementation.
- Share the current version: Initially, all users use the same software version.
- Split users and implement the “canary”: The new version (also known as the canary instance) is shared with a small group of users (usually about 5-10%), while your remaining users don’t experience any changes.
- Test the new version: The software development team verifies that the canary instance works properly. To do this, they run various types of tests (such as smoke tests) to evaluate the performance and effects of the changes.
- Decide on the implementation of the new version: Currently, this process is usually done automatically by analyzing several criteria.
If the canary instance meets expectations, it is gradually sent to more user traffic. For example, if it was initially sent to 10%, it is next sent to 20%, and so on. These numbers depend on the development team’s needs and can be set as needed.
On the other hand, if the new version contains bugs, it is simply disabled. All users are again given access to the previous version.
- Send 100% of user traffic to the new version: If the canary meets expectations, it is gradually rolled out until all users receive the new version of the software.
When and why to use Canary Deployment?
When you have finally made the decision to make changes to your software because it lacks a requirement and you want to add a new feature, this is the right time to use the Canary Deployment technique. Why? Because it proceeds in phases. This will save you from downtime after the release and deliver a smooth experience to your users.
Canary Deployment – Advantages
- It saves the software from crashing down and losing traffic during the update
- Makes the software work perfectly while changes are being implemented
- Canary Deployment is platform-independent; it can be applied to a website, desktop, or mobile application. Unleash provides SDKs for a large number of programming languages
- It is also deployable to the cloud and hybrid software solutions
- This technique allows one to observe and carefully consider the metrics about how the update is impacting the production and users
- The deployment can be reversed safely if some issues occur
Canary Deployment – Disadvantages
One disadvantage of utilizing canary deployment is that you need to deal with different variants of your software simultaneously. You can even choose to have multiple renditions running in production simultaneously; be that as it may, it is ideal to downplay the number of contemporary changes.
Another situation where utilizing canary deployment is difficult is the point at which you disperse software that is introduced in the clients’ PCs or cell phones. In this situation, you have less control over when they move up to the new version.
Contemplating the changes in the database is highly complicated in canary deployment.
When should you make the shift to canary deployment?
If the software your team is working on needs frequent updates, and you often implement new features, then canary deployments can be a great solution.
On the other hand, if you see that your team’s operations are not fully effective, that each change takes you a long time, and/or you are losing users through software bugs, it might be time for a change.
With the canary release, you will reduce the stress and risk associated with each new software update. You’ll be able to test new changes and monitor how they affect system performance and user satisfaction.
Furthermore, if you use a solution that provides a feature management option, you can deploy features in minor versions for select user groups.
For example, Unleash uses feature flags to separate canary deployments from canary releases. The process is simple, safe, and easy. This lets you deploy code faster and more efficiently without waiting for the entire release.
With Unleash, you can choose from a variety of canary release strategies that allow you to enable new features for everyone (standard), selected users with an identifier on the list (userID), and parameterized rollout (gradual rollout).
Unleash is open source at its core, so you have complete flexibility in how you use it in your business to best understand your users’ needs.
Typical Canary Deployment Strategies
The fundamental complication of canary deployment is devising an approach to direct a few clients to the new application. Likewise, some applications may consistently require a similar group of clients for testing, while others may need an alternate group without fail.
Adopt the following strategies
- Dispose of the canary deployment to the internal users first and then head towards external users
- Assign the routing on the basis of IP addresses
- Launch the new version in specific geolocation in the world
- First, make use of app logic to introduce a new version to a particular group of users. Test it and remove the logic when the application is all set to launch entirely
Feature flags and canary deployments: the best of both worlds
Canary deployments are a foundational approach for deploying new software versions with high confidence and low risk by exposing the new version to a limited audience. Feature flags also provide the same benefits but with more granular control:
– Precisely target specific user segments for feature rollouts.
– Maintain session consistency (stickiness) if needed.
– Test multiple features independently on different user groups simultaneously.
Often, canary deployments are managed at the load balancer level, reducing the risk of bad deployments by exposing the new code gradually to users. Feature flags act at the application level, reducing risk by providing fine-grained control over which features are released.
In some instances, rolling out groups of features together behind a feature flag can serve the purpose of a canary deployment. Feature flags represent an evolution in releasing flexibility. While canary deployments remain a valuable technique, feature flags provide a more powerful and versatile approach for managing complex releases. With feature flags, you can separate feature releases from deployments.
Implementing Canary deployment using Unleash
Step 1 is to create a new feature flag in Unleash and use the UserWithId activation strategy. In the management view of Unleash, define the users who will have access to the newly deployed feature.
This will enable the new feature only for the listed users. The users defined in the management view have to be available in the context where the unleash SDK is running.
Step 2 is to enable the feature for 1% of the user population. In unleash-hosted, the gradual rollout activation strategy is used. In this example, I’m using the “gradualRolloutUserId” activation strategy. This strategy will include the UserId in the hash to make sure that the same user gets consistent behavior during the Canary deployment.
If a user visits the same site multiple times over the days or weeks when the new feature is being rolled out, the user will always get or not get access to the feature – as long as the rollout percentage is not changed. Use the slider to set the proper percentage – in the example below, the activation is set to 1%.
Step 3 is validating the metrics chosen to confirm the implementation is as expected. Please use your favorite Application monitoring system for this step.
Step 4 is to gradually increase the percentage and repeat step 3.
Six Best Canary Deployment Practices
- Continuously use canaries (deploy in phases)
- Consider the suitable time for implementing Canary
- Abstain from concentrating canaries on anomalies in your administration pool
- For basic administrations, implement more canaries (phases) and screen them for longer periods
- Your canary procedure should cover 5% to 10% of your administration’s burden
- Your canary deployment coverage should be small enough that total disappointment of the underlying canary set won’t overpower the rest of it working
Deploying new features without risk? It’s possible
As you can see, a canary deployment strategy works great for many businesses. However, without the right management solution, it is challenging and involves some level of risk in many organizations. This is especially true if your team is overloaded with work and doesn’t have time for additional analysis of user behavior.
But what if we told you there is a solution that allows you to implement new changes in small releases while reducing cost, time, and any potential risk?
Here you go!
Check out our open-source software, which guarantees all the above-mentioned benefits and many more. What’s important is that it enables consistent behavior, so you won’t lose clients because of risky changes and any new feature stays consistent across all users.
Try us out and see why feature management is pretty fantastic.