Help Center/ Elastic Load Balance/ Best Practices/ Using Advanced Forwarding for Application Iteration
Updated on 2024-07-11 GMT+08:00

Using Advanced Forwarding for Application Iteration

Scenarios

As the business grows, you may need to upgrade your application based on user feedback. In this process, you can use advanced forwarding to redirect requests from users to both the new and old version first. When the application of the new version runs stably, direct all the requests to the new version.

Prerequisites

Six ECSs are available, with three having the application of the old version deployed and the other three having the new version deployed.

Process for Configuring Advanced Forwarding

Figure 1 Flowchart
Table 1 Resource planning

Resource Name

Resource Type

Description

ELB-Test

Dedicated load balancer

Only dedicated load balancers support advanced forwarding.

Server_Group-Test01

Backend server group

Used to manage the ECSs where the application of the old version is deployed.

Server_Group-Test02

Backend server group

Used to manage the ECSs where the application of the new version is deployed.

ECS01

ECS

Used to deploy the application of the old version and added to Server_Group-Test01.

ECS02

ECS

Used to deploy the application of the old version and added to Server_Group-Test01.

ECS03

ECS

Used to deploy the application of the old version and added to Server_Group-Test01.

ECS04

ECS

Used to deploy the application of the new version and added to Server_Group-Test02.

ECS05

ECS

Used to deploy the application of the new version and added to Server_Group-Test02.

ECS06

ECS

Used to deploy the application of the new version and added to Server_Group-Test02.

In this practice, the dedicated load balancer is in the same VPC as the ECSs. You can also add servers in a different VPC or in an on-premises data center as needed. For details, see Using IP as a Backend to Route Traffic Across Backend Servers.

Step 1: Configure a Dedicated Load Balancer

  1. Log in to the management console.
  2. In the upper left corner of the page, click and select the desired region and project.
  3. Click in the upper left corner to display Service List and choose Networking > Elastic Load Balance.
  4. In the upper right corner, click Buy Elastic Load Balancer.
  5. Create a dedicated load balancer and configure the parameters as follows.
  6. Add an HTTP listener to ELB-Test. For details, see Adding a Listener.
  7. Enable advanced forwarding. For details, see Advanced Forwarding Policy.
    Figure 2 Enabling advanced forwarding

Step 2: Create Two Backend Server Groups and Adde Backend Servers to Them

  1. Log in to the management console.
  2. In the upper left corner of the page, click and select the desired region and project.
  3. Click in the upper left corner to display Service List and choose Networking > Elastic Load Balance.
  4. In the navigation pane on the left, choose Elastic Load Balance > Backend Server Groups.
  5. Click Create Backend Server Group in the upper right corner.
    • Name: Server_Group-Test01
    • Load Balancer: Select ELB-Test.
    • Backend Protocol: HTTP
    • Configure other parameters as required.
  6. Repeat Step 5 to create backend server group Server_Group-Test02.
  7. Add ECS01, ECS02, and ECS03 to backend server group Server_Group-Test01.
  8. Add ECS04, ECS05, and ECS06 to backend server group Server_Group-Test02.

Forwarding Requests to Different Versions of the Application based on HTTP Request Methods

Configure two advanced forwarding policies with the HTTP request method as the condition to route GET and DELETE requests to the application of the old version and POST and PUT requests to the application of the new version. When the application of the new version runs stably, direct all the requests to the new version.

Figure 3 Forwarding requests based on HTTP request methods
  1. Locate the dedicated load balancer and click its name ELB-Test.
  2. On the Listeners tab, locate the HTTP listener added to the dedicated load balancer and click its name.
  3. Switch to the Forwarding Policies tab on the right, and click Add Forwarding Policy to forward requests to application of the old version.

    Select GET and DELETE from the HTTP request method drop-down list, select Forward to a backend server group for Action, and select Server_Group-Test01 from the drop-down list.

    Figure 4 Forwarding GET and DELETE requests to the application of the old version
  4. Click Save.
  5. Repeat the preceding steps to add a forwarding policy to forward PUT and POST requests to the application of the new version.

    Select PUT and POST from the HTTP request method drop-down list, select Forward to a backend server group for Action, and select Server_Group-Test02 from the drop-down list.

    Figure 5 Forwarding PUT and POST requests to the application of the new version

Forwarding Requests to Different Versions of the Application based on HTTP Headers

If the old version supports both Chinese and English, but the new version only supports English because the Chinese version is still under development, you can configure two advanced forwarding policies with the HTTP header as the condition to route requests to the Chinese application to the old version and requests to the English application to the new version. When the application of the new version supports the Chinese, direct all the requests to the new version.

Figure 6 Smooth application transition between the old and new versions based on the HTTP request header
  1. Locate the dedicated load balancer and click its name ELB-Test.
  2. On the Listeners tab, locate the HTTP listener added to the dedicated load balancer and click its name.
  3. Switch to the Forwarding Policies tab on the right, and click Add Forwarding Policy to forward requests to application of the old version.

    Select HTTP header from the drop-down list, set the key to Accept-Language and value to en-us, set the action to Forward to a backend server group, and select Server_Group-Test01 as the backend server group.

    Figure 7 Forwarding requests to the application of the old version
  4. Click Save.
  5. Repeat the preceding steps to add a forwarding policy to forward requests to the application of the new version.

    Select HTTP header from the drop-down list, set the key to Accept-Language and value to zh-cn, set the action to Forward to a backend server group, and select Server_Group-Test02 as the backend server group.

    Figure 8 Forwarding requests to the application of the new version

Forwarding Requests to Different Versions of the Application based on Query Strings

If the application is deployed across regions, you can configure two advanced forwarding policies with query string as the condition to forward requests to the application in region 1 to the old version and requests to the application in region 2 to the new version. When the application of the new version runs stably, direct all the requests to the new version.

Figure 9 Forwarding requests based on query strings
  • Dedicated load balancers can distribute traffic across regions or VPCs.
  • In this example, you need to use Cloud Connect to connect the VPCs in two regions and then use a dedicated load balancer to route traffic to backend servers in the two regions.
  1. Locate ELB-Test and click its name.
  2. On the Listeners tab, locate the HTTP listener added to the dedicated load balancer and click its name.
  3. Switch to the Forwarding Policies tab on the right, and click Add Forwarding Policy to forward requests to application of the old version.

    Select Query string from the drop-down list, set the key to region and value to region01, set Action to Forward to a backend server group, and select Server_Group-Test01 as the backend server group.

    Figure 10 Forwarding requests to the old version
  4. Click Save.
  5. Repeat the preceding steps to add a forwarding policy to forward requests to the application of the new version.

    Select Query string from the drop-down list, set the key to region and value to region02, set Action to Forward to a backend server group, and select Server_Group-Test02 as the backend server group.

    Figure 11 Forwarding requests to the new version