All Products
Search
Document Center

Global Accelerator:Examples on how to configure the traffic distribution feature for multiple endpoint groups

Last Updated:Jan 17, 2024

You can use the traffic provisioning feature to control the access ratio of endpoint groups in different regions.

Scenarios

A company deploys a service on servers in the China (Beijing) and China (Shanghai) regions. The TCP protocol is used and port 80 is open. The clients are located in the China (Beijing) region. The company specifies China (Beijing) as the acceleration region and creates an endpoint group in the China (Beijing) and China (Shanghai) regions in the Global Accelerator (GA) console. By default, GA forwards all requests from clients in the China (Beijing) region to the servers in the endpoint group that is deployed in the China (Beijing) region. The endpoint group in the China (Shanghai) region serves as the secondary endpoint group. If the endpoint group in the China (Beijing) region is abnormal, client requests are forwarded to the endpoint group in the China (Shanghai) region. Due to business development, the company wants to forward requests from clients in the China (Beijing) region to the servers in the endpoint group that is deployed in the China (Shanghai) region. The company also wants to ensure that clients can access the service as normal during the switchover process.

You can change the traffic distribution ratio for the endpoint group in the China (Beijing) region. For example, you can change the traffic distribution ratio from 100% to 50%. This way, 50% of requests from clients in the China (Beijing) region are forwarded to the servers in the endpoint group in the China (Shanghai) region. If clients can access the service as normal, change the traffic distribution ratio to 0%. This way, all requests from clients in the China (Beijing) region are forwarded to the servers in the endpoint group in the China (Shanghai) region. This ensures the seamless switchover of traffic from clients in the China (Beijing) region.

场景示例

Prerequisites

A GA instance and a basic bandwidth plan are purchased. For more information, see Select and purchase GA resources.

Procedure

配置步骤

Step 1: Deploy servers

The servers in this example run the Alibaba Cloud Linux 3.2104 64-bit operating system. The command that is used to run the test may vary based on the operating system. For more information, refer to the user guide of the operating system.

  1. Deploy servers in the China (Beijing) and China (Shanghai) regions, and specify the TCP protocol and open port 80 for the servers.

  2. Open the command prompt on a client in the China (Beijing) region and run the curl command to access the servers in the China (Beijing) region and the China (Shanghai) region.

    curl <Origin IP address>

    The following figures show the region information that is returned.

    Figure 1. Access a server in the China (Beijing) region 访问北京服务器

    Figure 2. Access a server in the China (Shanghai) region 访问上海服务器

Step 2: Add an acceleration region

  1. Log on to the GA console.

  2. On the Instances page, find the GA instance that you created and click its ID.

  3. On the page that appears, click the Acceleration Areas tab. Then, click Add Acceleration Area.

  4. In the Add Acceleration Area dialog box, set the parameters and click OK. The following table describes the parameters.

    Parameter

    Description

    Select Acceleration Region

    Select the region where the users that require the acceleration service are located.

    In this example, China (Beijing) is selected. Then, click Add.

    Assign Bandwidth

    Allocate bandwidth to the region.

    In this example, 2 Mbit/s of bandwidth is allocated.

    IP Protocol

    Select the protocol that is used by the users to connect to GA.

    In this example, IPv4 is selected.

    After you add the region, the system assigns an accelerated IP address to the region that is added to the GA instance. This accelerated IP address is used to accelerate data transfer from users in the specified region to the specified backend servers through GA.

Step 3: Add a listener and an endpoint group

  1. On the instance details page, click the Listeners tab and then click Add Listener.

  2. In the Configure Listener & Protocol step, configure the parameters and click Next. The following table describes the parameters.

    监听

    Parameter

    Description

    Listener Name

    Enter a name for the listener.

    The name must be 2 to 128 characters in length, and can contain letters, digits, underscores (_), and hyphens (-). The name must start with a letter.

    Protocol

    Select a protocol for the listener.

    In this example, TCP is selected.

    Port Number

    Specify a port for the listener to receive and forward requests to endpoints. Valid values:1 to 65499.

    In this example, port 80 is used.

    Client Affinity

    Specify whether to enable client affinity. If you enable client affinity, requests from the same client are forwarded to the same endpoint when the client connects to a stateful application.

    In this example, Disable is selected.

  3. On the Configure Endpoint Group wizard page, configure the following parameters for the endpoint group that is deployed in the China (Beijing) region.

    The following table describes only the parameters that are relevant to this topic. For more information, see Create and manage the endpoint groups of intelligent routing listeners.

    Parameter

    Description

    Endpoint Group Name

    Enter a name for the endpoint group.

    Select Acceleration Region

    Select the region where you want to create the endpoint group. IPv6 clients can access only servers deployed in the specified region.

    In this example, China (Beijing) is selected.

    Endpoint Configuration

    Client requests are routed to endpoints. To add an endpoint, configure the following parameters:

    • Backend Service Type: Select the type of the beckend service. In this example, Custom IP is selected.

    • Backend Service: Enter the public IP address of the backend server.

    • Weight: Enter a weight for the endpoint. Valid values: 0 to 255. GA routes network traffic to endpoints based on the weights of the endpoints.

    Warning

    If you set the weight of an endpoint to 0, Global Accelerator stops distributing network traffic to the endpoint. Proceed with caution.

    Preserve Client IP

    Specify whether to enable the client IP address preservation feature.

    If you enable the client IP address preservation feature, backend servers can obtain client IP addresses. If the listener uses the TCP protocol and you enable the client IP address preservation feature, you may need to configure the backend server to obtain the client source IP address. For more information, see Preserve client IP addresses.

    In this example, Preserve Client IP is disabled.

    Traffic Distribution Ratio

    Specify a traffic distribution ratio for the endpoint group. Unit: %. Valid values: 0 to 100.

    In this example, the default value 100 is used.

    Note

    You can set the Traffic Distribution Ratio parameter only when you create an endpoint group for a TCP or UDP listener.

    Health Check

    Specify whether to enable the health check feature.

    After you enable this feature, you can use health checks to check the status of endpoints. For more information about how to configure health checks, see Enable and manage health checks.

    In this example, the health check feature is enabled.

  4. Click + Add Endpoint Group to add another endpoint group in the China (Shanghai) region, configure the endpoint group based on the parameter description in Substep 3, and then click Next.

  5. On the Confirm wizard page, confirm the configurations of the listener and endpoints and click Submit.

Step 4: Test the traffic distribution result

In this example, the following command is used to simulate client requests to test the traffic distribution result.

echo > curl.txt; for ((i=0;i<<Number of requests>;i++)); do curl -s <Accelerated IP address> >> curl.txt; done; beijing_count=`grep Beijing curl.txt | wc -l`;echo "Beijing count: ${beijing_count}";shanghai_count=`grep Shanghai curl.txt | wc -l`;echo "shanghai count: ${shanghai_count}";

The following section describes the parameters:

  • Number of requests: The number of client requests that are simulated. For example, if you set Number of requests to 100, 100 requests are sent from the client.

  • Accelerated IP address: The accelerated IP address assigned by GA.

  • Beijing count: The number of requests processed by the servers in the China (Beijing) region.

  • Shanghai count: The number of requests processed by the servers in the China (Shanghai) region.

  1. Check how client requests are scheduled when you set the traffic distribution ratio to 100% for the endpoint group that is assigned a higher priority in the China (Beijing) region.

    Open the command prompt on a client in the China (Beijing) region and send 100 requests. Then, check the number of requests that are processed by the servers in the China (Beijing) region and the number of requests that are processed by the servers in the China (Shanghai) region.测试流量调配100

    The result indicates that all requests from the client in the China (Beijing) region are forwarded to the endpoint group in the China (Beijing) region.

  2. Check how client requests are scheduled when you set the traffic distribution ratio to 50% for the endpoint group that is assigned a higher priority in the China (Beijing) region.

    1. Change the traffic distribution ratio to 50% for the endpoint group in the China (Beijing) region. For more information, see Create and manage the endpoint groups of intelligent routing listeners.

    2. Send 100 requests from a client in the China (Beijing) region and check the number of requests that are processed by the servers in the China (Beijing) region and the number of requests that are processed by the servers in the China (Shanghai) region.

      测试流量调配50

      The result indicates that each endpoint group in the China (Beijing) region and the China (Shanghai) region processes 50 requests.

  3. Check how client requests are scheduled when you set the traffic distribution ratio to 0% for the endpoint group that is assigned a higher priority in the China (Beijing) region.

    1. Change the traffic distribution ratio to 0% for the endpoint group in the China (Beijing) region. For more information, see Create and manage the endpoint groups of intelligent routing listeners.

    2. Send 100 requests from a client in the China (Beijing) region and check the number of requests that are processed by the servers in the China (Beijing) region and the number of requests that are processed by the servers in the China (Shanghai) region.

      测试流量调配0

      The result indicates that all requests from the client in the China (Beijing) region are forwarded to and processed by the servers in the China (Shanghai) region.