Deployment Strategies: Canary
Tags: deployment, canarydeploymen, softwaredeployment, softwareengineering
Published: 2023-08-28 09:48:03

A canary deployment is a gradual deployment strategy in which a new version of an application is rolled out to a small percentage of users first. This allows you to test the new version in production without affecting all of your users.

## Used for

- To test new features or bug fixes (improving safety and reliability) before they are rolled out to all users.
- Also can be used to test new infrastructure or deployment tools of a product with a huge clientele.

## Advantages

- **Reduced risk of downtime:** If there is a problem with the new version, it will only affect a small percentage of users. This can help to minimize the impact of downtime.
- **Improved Monitoring:** By gradually rolling out the new version, you can monitor its performance and identify any problems early on.
- **Increased user acceptance:** By testing the new version with a small group of users first, you can
get feedback and make changes before it is rolled out to everyone.

## Disadvantages

- **Can be time-consuming to set up and manage.** Canary deployments require you to have a staging environment where you
can test the new version of your application before deploying it to
production. This can add time and complexity to your deployment process.
- **Can be difficult to get right.** It can be difficult to determine the right percentage of users to serve the new version of your application. If you serve too few users, you
may not be able to identify any problems with the new version. If you
serve too many users, you may experience downtime or errors.
- **Can be disruptive to users.** If you are serving the new version of your application to a small
percentage of users, it is possible that some users will experience problems. This can be disruptive to their experience and may cause them to abandon your application.

## Tips for minimizing the disadvantages

- Use a staging environment exactly the same as the production environment (as much as possible) — help to identify any problems with the new version before deployed to production.
- Monitor the performance of the new version closely and collect feedback from end users to identify any problems as early as possible.
- Having a rollback plan in place and preparing for Hotfix situation in case of any issue in the new version. This will help you to quickly restore the previous version of the application.

## Beta release vs. Canary deployment

| Feature | Beta release | Canary deployment |
| --- | --- | --- |
| Purpose | To test an application with a small group of users before it is released to the general public. | To gradually roll out a new version of an application to production and monitor its performance. |
| Audience | A small group of users who are willing to test the application and provide feedback. | A small percentage of all users (real user). |
| Timing | The beta release is typically released before the application is released to the general public. | The canary deployment is typically released after the application has been tested in a staging environment. |
| Goals | To identify and fix bugs, get feedback on the application's features, and improve the application's performance. | To reduce the risk of downtime and errors, improve the application's performance, and get feedback on the application's features. |

## Possible steps to do canary deployment

1. Create a new version of the application.
2. Deploy the new version to a staging environment and test it thoroughly.
3. Deploy the new version to a small percentage of production users.
4. Monitor the performance of the new version and collect feedback from users.
5. If the new version is performing well, gradually increase the percentage of users who are served the new version.
6. If there are any problems with the new version, roll back to the previous version.