All Products
Search
Document Center

:Use GTM to implement multi-acitive load balancing and disaster recovery

Last Updated:Apr 18, 2025

Scenarios

Your application service is deployed in two data centers, such as Data Center A and Data Center B, and each data center uses a public IP address for ingress traffic. You hope that the application service works in the following ways: Traffic is proportionally distributed to the two data centers when the data centers work normally. The system can detect failures in time and does not distribute traffic to the corresponding faulty IP address when one of the data centers fails. When the faulty data center recovers, its IP address is automatically added to the IP address list for DNS resolution. Then, the system can continue to support traffic balancing.

Prerequisites

  • The domain name cloud-example.com is hosted by Alibaba Cloud DNS. You want to connect the business domain name www.cloud-example.com to Global Traffic Manager (GTM).

    Note

    If your business domain name is not hosted by Alibaba Cloud DNS, you can also use GTM. You need to add a canonical name (CNAME) record to DNS settings of the current DNS service provider of the business domain name to map the business domain name to the corresponding access domain name in GTM.

  • A GTM instance, for example, gtm-cn-7213oh**902, is purchased. To purchase an instance, see Purchase an instance.

  • The following traffic scheduling is required.

    Source of DNS requests

    IP address of application service

    Weight ratio

    Global default

    1.1.XX.XX, 2.2.XX.XX

    1:1

    Note

    You can adjust the ratio based on your business requirements. A larger weight indicates a larger number of times that the address is returned for DNS requests.

Procedure

  1. Log on to the Alibaba Cloud DNS console.

  2. In the left-side navigation pane, click Global Traffic Manager to go to the Global Traffic Manager 3.0 page.

  3. On the Access Domain Name tab, click Create Access Domain Name.

  4. In the Select Scenario dialog box, select Multi-active Load Balancing.

  5. On the Create Access Domain Name page, move the pointer over the access domain name icon and click Basic Configuration.

  6. In the Basic Access Domain Name Configuration panel, configure the parameters and click Submit. For more information about how to configure an access domain name, see Configure an access domain name. image

  7. On the Access Domain Name page, move the pointer over an Address Pool icon and click Basic Configuration. For more information, see Basic configuration parameters in the Configure an address pool topic.

  8. On the Access Domain Name page, move the pointer over an Address icon and click Basic Configuration. In the Basic Address Configuration panel, add an address, configure one or more health check templates and other parameters, and then click Submit. In this example, tcp is selected for the Detection Protocol parameter and port 80 is selected for the Port Number parameter of health checks. Repeat this step to add addresses and associate them with health check templates.

    Note

    If no health check template is created, click Quickly Add Detection Template to create one. For more information, see Health check templates.

    image

    Important

    This example demonstrates the configuration procedure. If red or orange alert items appear in the actual configuration, check the address health status at the earliest opportunity.

  9. Usually, you do not need to configure load balancing policies because the scenario-specific template automatically generates policies.

    Note

    If you need to adjust the weight ratio, you can move the pointer over the weight value above an address and click Weight Configuration to modify the value.

    Important

    You may find that DNS records are not returned based on the weight settings during the test. This is a common occurrence. The cause is that weighted round-robin is a coarse-grained method to schedule traffic based on the weight of an address in a DNS record. Weighted round-robin is set to process requests from local DNS servers. However, local DNS servers request the authoritative DNS, which is Alibaba Cloud DNS in this example, only once within the time to live (TTL) period.

    For example, your domain name is visited by users in both the China (Shanghai) and China (Beijing) regions. In this example, Local DNS A is specified to process requests from users in Shanghai and Local DNS B is specified to process requests from users in Beijing. When Local DNS A and Local DNS B initiate queries to GTM, GTM returns addresses based on the configured weight values. However, GTM returns the same addresses to all users that are specified with the same local DNS server within the TTL period.

  10. Configure alert settings for the instance. For more information, see Procedure in the Configure alert settings topic.

  11. On the Access Domain Name page, move the pointer over the Access Domain Name icon and click Enable. image

  12. In the Confirm Access Domain Name Enabling dialog box, confirm that the configuration of the access domain name is correct and click OK.

    Important
    • If a domain name record with the same name and the same type exists in the Authoritative DNS Resolution module of Alibaba Cloud DNS, the system first intelligently schedules and resolves DNS requests for this domain name based on the policy configured in GTM to implement advanced features such as traffic load balancing and failovers.

    • If you disable or delete this access domain name in GTM, requests for this domain name will be resolved by the Authoritative DNS Resolution module of Alibaba Cloud DNS.