Canary releases allow applications of old and new versions to be deployed in parallel. You can apply the new version to a small percentage of users before rolling out to the entire user base. With canary releases, you can control the percentage of users that are exposed to the old and new versions based on your business requirements.

Scenario

When you build an application, you want to speed up the release process while ensuring user experience. To reduce the risk of errors in the new version disrupting your workflow, you want to implement canary releases and allow the new version to receive service traffic from a subset of users. Then, you can evaluate the new version against metrics such as logs, performance, and stability based on feedback from the canary users. You can incrementally roll out the new version to the entire user base or roll back to the old version based on the evaluation.

Preparations

  1. Deploy the old and new versions on different backend servers. To ensure service availability, you can deploy each version on multiple backend servers.
  2. Create an ALB instance. For more information, see Create an ALB instance.
  3. Create server groups. Then, add the backend servers where the old and new version are deployed to different server groups. For more information, see Create and manage a server group.
  4. Create a listener. Then, add the backend servers where the old version is deployed to the default server group of the listener. For more information, see Add an HTTP listener, Add an HTTPS listener, and Add a QUIC listener.

    After you complete the preceding tasks, all requests are forwarded to the old version. You can use one or more of the following methods to implement canary releases.

Canary releases based on HTTP headers

In this example, HTTP requests that contain the User-Agent header *Mozilla/4.0* are forwarded to the new version.

header
  1. Log on to the ALB console.
  2. In the top navigation bar, select the region where the ALB instance is deployed.
  3. On the Instances page, click the ID of the Application Load Balancer (ALB) instance that you want to manage.
  4. On the Listener tab, find the listener and click View/Modify Forwarding Rule in the Actions column.
  5. Choose Forwarding Rules > Inbound Forwarding Rules and click Add Forwarding Rules.
  6. Set the parameters and click OK.
    • Forwarding Condition: Select HTTP Header from the drop-down list, set the key to user-agent, and then set the value to *Mozilla/4.0*.
    • Forwarding Action: Select Forward from the drop-down list and select Server New version.
    For more information about the parameters, see Manage forwarding rules for a listener.
  7. You can configure more forwarding rules to increase the percentage of user traffic distributed to the new version. If the new version works as expected, you can discontinue the old version and forward all requests to the new version.

Canary releases based on cookies

This example shows how to configure ALB to forward requests to the new version based on cookies that are specified in key-value pairs.

Basic ALB instances do not support this feature. You must upgrade to the ALB edition before you can use this feature. For more information, see Modify the configurations of ALB instances.

cookie
  1. Log on to the ALB console.
  2. In the top navigation bar, select the region where the ALB instance is deployed.
  3. On the Instances page, click the ID of the ALB instance that you want to manage.
  4. On the Listener tab, find the listener that you want to manage and click View/Modify Forwarding Rule in the Actions column.
  5. Choose Forwarding Rules > Inbound Forwarding Rules and click Add Forwarding Rules.
  6. Set the parameters and click OK.
    • Forwarding Condition: Select Cookie from the drop-down list and set the value to key: value.
    • Forwarding Action: Select Forward from the drop-down list and select Server New version.
    For more information about the parameters, see Manage forwarding rules for a listener.
  7. You can configure more forwarding rules to increase the percentage of user traffic distributed to the new version. If the new version works as expected, you can discontinue the old version and forward all requests to the new version.

Canary release based on server groups

In this example, 80% of the requests destined for www.test.com are forwarded to the old version and 20% of the requests are forwarded to the new version.

Diagram
  1. Log on to the ALB console.
  2. In the top navigation bar, select the region where the ALB instance is deployed.
  3. On the Instances page, click the ID of the ALB instance that you want to manage.
  4. On the Listener tab, find the listener that you want to manage and click View/Modify Forwarding Rule in the Actions column.
  5. Choose Forwarding Rules > Inbound Forwarding Rules and click Add Forwarding Rules.
  6. Set the parameters and click OK.
    • Forwarding Condition: Select Domain Name from the drop-down list and set the value to www.test.com.
    • Forwarding Action: Select Forward from the drop-down list, and select Server Old version(set the weight to 80) and Server New version (set the weight to 20).
    For more information about the parameters, see Manage forwarding rules for a listener.
  7. You can change the weights of the server groups to meet your business requirements. If the new version works as expected, you can discontinue the old version and forward all requests to the new version.