When your service is deployed across multiple regions, traffic distribution lets you control the percentage of traffic routed to each endpoint group, enabling smooth cross-region traffic shifts.
Traffic distribution ratio
Each endpoint group has a traffic distribution ratio between 0% and 100% (default: 100%).
0% — no traffic is forwarded to this endpoint group.
100% — all available traffic is forwarded to this endpoint group.
GA determines which endpoint group to use first based on scheduling priority, which reflects network latency between the nearest access point and the endpoint group. The closer the access point is to the endpoint group's region, the higher the priority. Traffic is always sent to the highest-priority healthy endpoint group first, and the distribution ratio is applied on top of that routing decision.
For subscription billing, only TCP and UDP listeners support traffic distribution. For pay-as-you-go billing, all listener types support traffic distribution.
When health checks are enabled:
If a higher-priority endpoint group fails its health check, GA forwards all traffic to the next available endpoint group with the highest priority. The configured traffic distribution ratio is ignored during failover.
When the failed endpoint group passes the health check again, GA automatically routes traffic back to it. No manual intervention is required.
If a custom forwarding policy exists, traffic is distributed among the endpoint groups associated with the matched forwarding policy.
Scenario
A company runs a TCP service on port 80 across servers in the China (Beijing) and China (Shanghai) regions, with most clients located in Beijing. The company uses GA with an acceleration area in China (Beijing) and two endpoint groups: Beijing (primary) and Shanghai (standby). By default, GA routes all Beijing client traffic to the Beijing endpoint group. The Shanghai endpoint group takes over only when the Beijing group becomes unavailable. The company now needs to temporarily shift all Beijing client traffic to the Shanghai endpoint group without disrupting service.
To achieve this, adjust the traffic distribution value for the Beijing endpoint group. For example, reduce it from the default 100% to 50% so that GA routes half the Beijing client traffic to Shanghai. After verifying correct forwarding, reduce the value to 0% so that GA routes all Beijing client traffic to Shanghai, completing a smooth traffic shift.
Procedure
This topic uses a pay-as-you-go, standard Global Accelerator instance as an example. Before you create a pay-as-you-go, standard Global Accelerator instance, make sure that you understand the following information:
GA instances use the pay-by-data-transfer metering method. You do not need to associate a basic bandwidth plan with pay-as-you-go GA instances. The billing of data transfer over the GA network is managed by Cloud Data Transfer (CDT). For more information, see Data transfer billing.
The first time you use a pay-as-you-go GA instance, you must Activate the Service.
Step 1: Deploy servers
This topic uses Alibaba Cloud Linux 3.2104 64-bit as an example. Test commands may vary by operating system. For specific commands, refer to your operating system's documentation.
Deploy servers in the China (Beijing) and China (Shanghai) regions and open TCP port 80.
Log on to a client in the China (Beijing) region, open a command-line window, and use the
curl <origin_server_ip>command to access the servers in the China (Beijing) and China (Shanghai) regions.
Step 2: Configure basic instance information
Log on to the GA console.
On the Instances page, click Create Standard Pay-as-you-go Instance.
In the Basic Instance Configuration step, configure the parameters based on the following table and click Next.
Parameter
Description
GA Instance Name
Enter a name for the GA instance.
Instance Billing Method
Pay-As-You-Go is selected by default.
You are charged instance fees, Capacity Unit (CU) fees, and data transfer fees for pay-as-you-go standard Global Accelerator instances.
For more information about instance fees and CU fees, see Pay-as-you-go Global Accelerator instance billing.
For more information about data transfer fees, see Data transfer billing.
Resource Group
Select the resource group to which the standard Global Accelerator instance belongs.
The resource group must be created by the current Alibaba Cloud account in Resource Management. For more information, see Create a resource group.
Step 3: Configure an acceleration area
Specify acceleration regions and allocate bandwidth to each acceleration region.
In the Configure Acceleration Area step, configure the parameters based on the following table and click Next.
Parameter | Description |
Acceleration Area | From the drop-down list, select one or more regions from which you want to accelerate access, and then click Add. In this example, select China (Beijing) from the North China area. |
Assign Bandwidth | |
Maximum Bandwidth | Set the bandwidth for the acceleration area. The value for each acceleration area can range from 2 to 10,000 Mbit/s. This value serves only as a rate limit. CDT settles the data transfer fees. In this example, keep the default value of 200 Mbit/s. Important Setting the maximum bandwidth too low may trigger rate limiting and cause traffic drops. |
IP Protocol | Select the IP protocol used to access the Global Accelerator service. In this example, keep the default value of IPv4. |
ISP Line Type | Select the public network line type used to access the Global Accelerator service. In this example, select BGP (Multi-ISP). |
Step 4: Configure a listener
A listener listens for connection requests and distributes the requests to endpoints based on the port and the protocol that you specify. Each listener is associated with an endpoint group. You can associate an endpoint group with a listener by specifying the region to which you want to distribute network traffic. After you associate an endpoint group with a listener, network traffic is distributed to the optimal endpoint in the endpoint group.
In the Configure Listeners step, configure a listener and click Next.
This section describes only the parameters relevant to this example. You can keep the default values for other parameters. For more information, see Add a TCP or UDP listener.
Parameter | Description |
Listener Name | Enter a name for the listener. |
Routing Type | Select the routing type. In this example, select Intelligent Routing. |
Protocol | Select the protocol for the listener. In this example, select TCP. |
Port | Specify the listener port that is used to receive and forward requests to endpoints. The port number must be in the range of 1 to 65499. In this example, enter 80. |
Step 5: Configure endpoint groups and endpoints
Configure the Beijing endpoint group.
On the Configure an Endpoint Group wizard page, configure the Beijing endpoint group with the following parameters and click Next.
This section describes only the parameters relevant to this example. For more information, see Add and manage endpoint groups for intelligent routing listeners.
Parameter
Description
Region
Select the region where the endpoint group is deployed.
In this example, select China (Beijing).
Endpoint Configuration
The target host that processes client requests. Configure the endpoint with the following parameters:
Backend Service Type: Select Custom Public IP.
Backend Service: Enter the IP address of the backend service to accelerate. In this example, enter the public IP address of the China (Beijing) server.
Weight: Enter the weight of the endpoint. Valid values: 0 to 255. GA routes traffic to endpoints based on their weights. In this example, keep the default value of 255.
WarningIf the weight of an endpoint is set to 0, Global Accelerator stops distributing traffic to that endpoint. Proceed with caution.
Preserve Client IP
Select whether to preserve client IP addresses.
If enabled, the backend server can retrieve the original client IP address. For more information, see Preserve client IP addresses.
In this example, keep the default setting Disabled.
Traffic Distribution Ratio
Set the percentage of traffic routed to this endpoint group.
The value ranges from 0 to 100. In this example, keep the default value of 100.
Health Check
Specifies whether to enable health checks. If enabled, GA monitors endpoint availability.
In this example, enable health checks.
Health Check Protocol
Select the protocol for the health check. The supported protocols are TCP, HTTP, and HTTPS.
In this example, select TCP.
Port
The port that the health check service uses to access the endpoint.Valid range: 1-65535.
In this example, enter 80.
On the Configuration Review wizard page, confirm the listener and endpoint settings, and then click Submit.
It may take 3 to 5 minutes to create the Global Accelerator instance.
Optional: After the instance is created, click Go to Instance Details. On the instance details page, you can view the configuration on the Instance Information, Listeners, and Acceleration Areas tabs.
Configure the Shanghai endpoint group.
On the instance details page, click the Listeners tab.
On the Listeners tab, find the target listener and click the endpoint group ID or the number in the Default Endpoint Group column.
On the Endpoint Group tab, in the Default Endpoint Group section, click + Add Endpoint Group.
On the Add Endpoint Group page, configure the following parameters and click Create.
Region: Select China (Shanghai).
Backend Service under Endpoint Configuration: Enter the public IP address of the China (Shanghai) server.
Keep the other parameters the same as those for the Beijing endpoint group.
Step 6: Test the traffic distribution
Send multiple requests from the client to verify the traffic distribution result:
echo > curl.txt
for ((i=0; i<<request-count>; i++)); do
curl -s <acceleration-ip> >> curl.txt
done
echo "Beijing count: $(grep -c Beijing curl.txt)"
echo "Shanghai count: $(grep -c Shanghai curl.txt)"<request-count>: the total number of requests to simulate, for example100.<acceleration-ip>: the acceleration IP assigned by GA.
In the scenario described in this topic, log on to the Beijing client and send 100 requests:
echo > curl.txt
for ((i=0; i<100; i++)); do
curl -s 123.xxx.xxx.xxx >> curl.txt
done
echo "Beijing count: $(grep -c Beijing curl.txt)"
echo "Shanghai count: $(grep -c Shanghai curl.txt)"Run this command three times — with the traffic distribution value of the higher-priority Beijing endpoint group set to 100%, 50%, and 0% respectively — and compare the request distribution across regions.
Related topics
For more information about health checks, see Enable and manage health checks.
For more information about the principles and use cases of traffic distribution, see Principles and use cases of traffic distribution across multiple endpoint groups.
You can combine traffic distribution with health checks to implement multi-region load balancing and disaster recovery. For more information, see Use GA to accelerate cross-region applications and implement high-availability disaster recovery.