Use GTM and CLB instances to implement cross-region load balancing

Updated at:

When services in one region fail, Global Traffic Manager (GTM) detects the failure through health checks and automatically reroutes DNS traffic to a healthy region—keeping your service online without manual intervention. This tutorial shows you how to pair GTM with Classic Load Balancer (CLB), a Server Load Balancer (SLB) offering, in two regions to build a cross-region active-passive architecture.

How it works

GTM operates at the DNS layer. It monitors the health of your CLB instances in each region and responds to DNS queries with the IP address of a healthy endpoint. When a regional failure is detected, GTM stops returning that region's IP address and directs all traffic to the other region.

GTM can manage IP addresses from Alibaba Cloud and other service providers, enabling hybrid cloud deployments.

Cross-region load balancing architecture diagram

In this tutorial, Elastic Compute Service (ECS) instances run behind CLB instances in two regions—China (Hangzhou) and China (Beijing). GTM is configured to route traffic to both regions under normal conditions and to fail over to the surviving region when one becomes unavailable.

For more information about GTM, see What is Global Traffic Manager?.

Prerequisites

Before you begin, make sure you have:

Step 1: Purchase a GTM instance

  1. Log in to the Alibaba Cloud DNS console.

  2. In the left-side navigation pane, click Global Traffic Manager.

  3. Click Purchase Instance.

  4. On the purchase page, configure the parameters and complete the payment. The default settings are used in this tutorial.

Step 2: Configure GTM

Configure the GTM instance

  1. On the Global Traffic Manager page, click the ID of the GTM instance, or click Configuration in the Actions column.

  2. If this is your first time configuring GTM, select Advanced Settings in the Select Configuration Method dialog box.

  3. On the Basic Settings tab, click Modify. In the Modify Basic Settings panel, configure the following parameters and click OK.

    Setting

    Value

    CNAME (Internet)

    Select Custom Access Domain Name. Enter the prefix and suffix of your domain name. After you save the settings, a CNAME record is automatically generated that maps your domain to the GTM instance.

    Global TTL Period

    Set the duration that DNS resolvers cache the IP address.

    Alert Group

    Select a contact group to receive notifications when an endpoint becomes unhealthy. The Cloud Monitor alert group appears in the list by default. See Create an alert contact or alert contact group.

Configure address pools

Each CLB instance must be placed in a separate address pool. This tutorial uses two address pools—one for each CLB instance.

Do not add both CLB instances to the same address pool. GTM requires each CLB public IP address to be in a different pool to route traffic independently.
  1. On the Address Pools tab, click Create Address Pool.

  2. In the Create Address Pool panel, set the Address parameter in the Addresses list to the public IP address of one of your CLB instances. Configure other parameters or use the default values, then click OK.

  3. Repeat the preceding steps to create a second address pool with the public IP address of the other CLB instance.

Configure health checks

Configure a health check for each address pool so that GTM can detect regional failures.

  1. On the Address Pools tab, find an address pool and click the Expand icon to expand its configuration.

  2. Click Add next to Health Check. In the Modify Health Check Settings panel, set the health check protocol and port to match the backend protocol and port of your CLB listener. Configure the remaining parameters or use the default values, then click OK.

  3. Repeat the preceding steps to configure a health check for the other address pool.

Configure an access policy

  1. On the Basic Settings tab, go to the Access Policy Type section and click Settings in the Geographical Location-based Access Policy card.

  2. On the Geographical Location-based Access Policy page, click Create Access Policy.

  3. In the Create Access Policy panel, configure the following parameters and click OK.

    Setting

    Value

    DNS Request Source

    Select Global to route traffic from different regions or Internet service providers (ISPs) to the address pools.

    Primary Address Pool Set

    Select the address pools in all regions.

Step 3: Verify the result

Verify both normal operation and failover behavior.

Test normal operation:

  1. Open a browser and access your service using the CNAME generated in Step 2.

  2. Confirm that the service loads successfully.

Test failover:

  1. Disable the backend services in one of the regions to simulate a fault.

  2. Wait a few seconds for the health check to detect the failure, then refresh the page.

  3. Confirm that the service is still accessible—traffic has been rerouted to the other region.

To view detailed failover logs, go to the Alert Logs tab of your GTM instance.

Scaling QPS with multiple CLB instances

When your business requires more than approximately 50,000 QPS—the upper limit of a single CLB instance—you can deploy multiple CLB instances behind GTM to scale QPS linearly. By distributing DNS-resolved traffic across multiple CLB instances, total capacity can reach 100,000 QPS or more.

Choosing a load balancing strategy

GTM supports two load balancing strategies for addresses within an address pool:

Strategy

Behavior

Round-robin

All available addresses are returned in rotation. The local DNS resolver selects which address to use for each connection.

Weighted

A single address is returned per DNS query, chosen according to the configured weight ratio.

For multi-CLB deployments, the Weighted strategy is recommended. It lets you assign weights proportional to each CLB instance's capacity, giving you precise and predictable traffic distribution across instances.

GTM 3.0 provides a Multi-active load preset template designed for this use case. The preset configures:

  • Inter-pool (access domain level): Round-robin strategy across address pools.

  • Intra-pool (address pool level): Weighted strategy within each pool, with each address defaulting to a weight of 1.

To use this preset, select Multi-active load when creating a new access domain in the GTM console.

DNS TTL and IP switchover delay

The DNS TTL for your GTM instance defaults to 10 minutes. Client-side DNS resolvers cache the resolved IP address for the duration of the TTL. When GTM changes the resolved address—for example, when redistributing load or removing an unhealthy endpoint—clients whose cache has not yet expired continue sending requests to the previously cached IP address until their TTL expires.

To reduce switchover delay, lower the Global TTL Period value in the basic settings of your GTM instance. Note that a shorter TTL increases DNS query frequency.

Note

When a single client sends a high volume of requests, DNS-based load balancing may not distribute traffic evenly, because the client reuses the same cached IP address for the full TTL duration. This is expected behavior. Across multiple independent clients, traffic converges to the configured weight ratios as expected.

What's next

Application Load Balancer (ALB) and Network Load Balancer (NLB) also support cross-region architectures. Choose the load balancer type that fits your protocol and traffic requirements: