Scenarios
Your application service is deployed in two data centers, such as A and B. Each data center uses a public IP address as a traffic entry point. You want the two data centers to balance traffic loads based on a specific ratio during normal operation. If one data center fails, the system promptly detects the failure and removes the IP address of the failed data center from DNS resolution. When the data center recovers, the system automatically adds its IP address back to DNS resolution to resume load balancing.
Prerequisites
The domain name
cloud-example.comuses Alibaba Cloud DNS. The service domain name to add to Global Traffic Manager (GTM) iswww.cloud-example.com.NoteIf your service domain name is not managed by Alibaba Cloud DNS, you can still use GTM. To do so, you must add a CNAME record with your current DNS provider that points to the GTM CNAME.
You have purchased a GTM instance with the ID
gtm-cn-7213oh**902. If you do not have an instance, you can purchase one.The desired traffic scheduling configuration is as follows:
Source of DNS queries
Application service endpoint
Weight ratio
Global Default
1.1.XX.XX, 2.2.XX.XX
1:1
NoteAdjust the ratio as needed. A higher weight value increases the frequency at which the corresponding endpoint is resolved.
Procedure
Go to Global Traffic Manager.
On the Access Zone Name tab, click Create Access Zone Name.
In the Select Scenario dialog box, select Multi-active Load Balancing.
On the Create Access Zone Name page, click the icon for the access domain name and select Basic Configuration.
On the Basic Configuration page, configure the parameters and click Submit. For more information about how to configure an access domain name, see Configure an access domain name.

On the Access Zone Name page, click the icon for the address pool and select Basic Configuration.
On the Access Zone Name page, click the address icon and select Basic Configuration. On the Basic Configuration page, add an endpoint, configure a health check template, and then click Submit. For example, you can configure the health check to use the TCP protocol to check port 80 of the server. You can use the same method to add other endpoints and associate them with health check templates.
NoteIf you have not yet created a health check template, click Add Health Check Template. For more information, see Health check templates.
ImportantThis example demonstrates the configuration procedure. If you see red or orange alerts during configuration, promptly check the health status of the endpoints.
A load balancing policy is not required. The scenario template automatically generates one.
NoteTo adjust the weight ratio, you can click the weight value above the address pool.
ImportantDuring testing, you may find that DNS resolution results sometimes do not match the configured weights. This is expected because weight-based routing is a coarse-grained traffic scheduling method that applies to requests from local DNS servers. A local DNS server queries the authoritative DNS server (Alibaba Cloud DNS) only once during the Time to Live (TTL) period.
For example, your domain name is accessed by users in Shanghai and Beijing. Assume that users in Shanghai use Local DNS A, and users in Beijing use Local DNS B. When Local DNS A and Local DNS B send query requests to GTM, GTM returns responses based on the configured weight policy. However, within the TTL period, all users who use the same local DNS server receive the same resolution result.
You can configure alert monitoring for the instance. For more information, see Configure alerts.
On the Access Zone Name page, click the icon for the desired domain name and select Enable.

Confirm the access domain name and click OK.
ImportantIf a DNS record with the same name and type exists in Alibaba Cloud DNS, GTM policies take precedence for queries of that record type. This enables intelligent scheduling and resolution for features such as load balancing and failover.
If you disable or delete the GTM instance, the domain name is resolved by Alibaba Cloud DNS.