Unleash

Canary releases with feature flags: how to

Deploying a new feature all of a sudden can introduce significant risks, impacting both company security and user experience. How can you minimize these risks while still delivering fast, frequent updates?

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. In this article, we’ll explore how canary releases, combined with feature flags, can streamline your deployment process and improve the reliability of your releases.

What is canary release?

Canary release (also called a canary deployment) 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 a canary release 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.

When should you make the shift to canary release?

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. 

Canary release – 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 release – 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.

Canary release 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

Using feature flags for canary releases

Feature flags provide the same benefits to deployments as canary releases but with more granular control:

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.

Why use feature flags for canary releases

Feature flags let you decouple canary deployment from canary release.

With Unleash you can deploy code without waiting for release, which not only gives you full control over deploying new features or updates but also lets you deliver better code faster. The only thing you need to do is select a group of users to release the new feature to.

These can be users in a specific region or with a specific device type, users who logged in before a specific date or time, or of course any combination of the above conditions, depending on the constraints of the canary deployment strategy.

Implementing Canary releases

Let’s walk through the steps to implement a canary release using Unleash.

Step 1

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.

A canary deployment strategy using user IDs

 

Step 2

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%.

Canary deployment with gradual rollout at 1 percent

 

Step 3

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

Step 4 is to gradually increase the percentage and repeat step 3.

 

How Unleash enables canary releases

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.

With the versatility and flexibility of feature flags, Unleash gives you full control over canary testing. You can run A/B tests and controlled experiments to get measurable results and better understand your users needs. And, of course, you can determine which tested version is better in the eyes of the targeted user population to deliver applications tailored to their expectations.

Unleash also provides the following tools for greater control and visibility

Feature rollout strategies

Easily configure which feature flags are enabled for which users. Unleash has built-in default strategies like Progress Rollout that make getting started easy. Custom constraints allow targeting feature rollouts based on any attribute you can imagine like geo, customer type, or arbitrary telemetry.

Advanced targeting

Specify constraints that must be satisfied for an activation strategy to be evaluated for a feature flag. This allows you to roll out a feature only to users in a specific region, schedule a feature to be released at a specific time, and much more!

feature-flag-advanced-targeting

 

Instant rollbacks

Unleash allows you to roll back any feature instantly with the click of a button or fully automated via our API. Rolling back features at runtime instead of relying on a code deploy is faster and reduces downtime and poor user experience that happen when features are misbehaving.

instant-feature-flag-rollback

 

Fully automated feature rollout and rollback

Unleash Signals enable you to take in telemetry from any system capable of emitting JSON metrics. Unleash Actions allow you to take those signals and automatically adjust rollout strategies, initiate rollbacks, or enable kill switches.

signals-actions-feature-flag-automation-screen-shot

 

Kill switches

Gracefully degrade system functionality when needed. Unleash makes it trivial to implement and maintain long-lived operational flags like Kill Switches so you can respond to specific region, schedule a feature to be released at a specific time, and much more!

feature-flag-kill-switch

 

Open metrics engine

You can use feature flag events to send impression data to an analytics tool you choose to integrate like Grafana, Prometheus, Splunk, Datadog or more. Our impression data gives developers a full view of the activity that could raise any alarms and be used for managing progressive rollouts. We make it easy to get our data, your application, and an analytics tool connected so you can collect, analyze, and report relevant data for your teams.

feature-flag-open-metrics-engine

 

Next Steps

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.

Share this article