All Products
Search
Document Center

Server Load Balancer:Use ALB to implement canary release

Last Updated:Apr 02, 2024

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 Application Load Balancer (ALB) instance. Basic ALB instances do not support cookie-based rules. You must create standard ALB instances. 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. In this example, the new version is added to Server Group A and the old version is added to Server Group B.

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.

image
  1. Log on to the ALB console.
  2. In the top navigation bar, select the region in which 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. On the Forwarding Rules tab, click Add New Rule.

  6. Configure the following parameters and click OK:

    • Add Condition: Select HTTP Header from the drop-down list, set the key to user-agent, and then set the value to *Mozilla/4.0*.

    • Action: Select Forward from the drop-down list and select Server Group A.

    For more information, see Manage forwarding rules for a listener.

    Note

    You can add 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.

image
  1. Log on to the ALB console.
  2. In the top navigation bar, select the region in which 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. On the Forwarding Rules tab, click Add New Rule.

  6. Configure the following parameters and click OK:

    • Add Condition: Select Cookie from the drop-down list and set the value to key: value.

    • Action: Select Forward from the drop-down list and select Server Group A.

    For more information, see Manage forwarding rules for a listener.

    Note

    You can add 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 example.com are forwarded to the old version and 20% of the requests are forwarded to the new version.

image
  1. Log on to the ALB console.
  2. In the top navigation bar, select the region in which 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. On the Forwarding Rules tab, click Add New Rule.

  6. Configure forwarding rules based on the following information and click OK:

    • Add Condition: Select Domain Name from the drop-down list and set the domain name to example.com.

    • Action: Select Forward from the drop-down list, and select Server Group B and Server Group A. Set the weight of Server Group B to 80 and Server Group A to 20.

    For more information, see Manage forwarding rules for a listener.

    Note

    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 so that all requests can be forwarded to the new version.