Updated on 2026-09-07 GMT+08:00

Using AZ Affinity to Minimize Access Latency

If you are using ELB to forward traffic to a TCP or UDP backend server group, you can enable AZ affinity to forward traffic across backend servers in the same AZ as the load balancer to reduce access latency.

AZ affinity will be available in more regions. See which regions support this feature on the console.

AZ Affinity Overview

ELB can distribute traffic across AZs. By default, a load balancer forwards traffic to all backend servers in a backend server group.

If AZ affinity is enabled for a backend server group, traffic will be distributed across the backend servers in the same AZ as the load balancer, minimizing the access latency.

Forwarding Even Unhealthy will not work if AZ affinity is enabled for a backend server group.

Figure 1 Traffic forwarding with AZ affinity enabled

Resource AZs

An AZ contains one or more physical data centers. Each AZ has independent cooling, fire extinguishing, moisture-proof, and electricity facilities. Within an AZ, compute, networking, storage, and other resources are logically divided into multiple clusters.

  • Load balancer AZ

    Dedicated load balancers can be deployed across AZs. If you select multiple AZs, a load balancer is created in each selected AZ.

    You can change the AZ of a load balancer by referring to Changing an AZ.

  • Backend server AZ
    Table 1 Backend server AZ

    Backend Server Type

    AZ

    Cloud server

    The AZ where the cloud servers are running.

    Supplementary network interface

    The AZ where their primary network interfaces are running.

    IP as backend server

    The AZ you select when adding IP as backend servers.

AZ Affinity Failover Threshold

A failover threshold is used to determine the health of an AZ. If the percentage or number of healthy servers in the AZ of the load balancer falls below the specified threshold, the load balancer will distribute requests to healthy servers in other AZs.
  • Percentage: number of healthy servers in an AZ/total number of servers in the AZ
  • Quantity: the number of healthy servers in an AZ

The health of each AZ is independent from each other and is determined based on the number or percentage of healthy backend servers in that AZ.

  • If the percentage is 0% or the quantity is 0, the AZ is always considered as healthy and traffic will be distributed across the servers in this AZ.
  • If health check is not enabled for a backend server group, all backend servers in the group are considered as healthy by default. So the AZ is also healthy.
  • If there is no backend server in the AZ of the load balancer, the AZ is considered unhealthy, and the AZ affinity failover function takes effect.
  • The health check result of a backend server with the weight of 0 is also used to calculate the AZ affinity failover threshold.

If you enable AZ affinity, traffic forwarding may be interrupted if the failover threshold and forwarding actions are not properly configured. So deploy your backend servers in different AZs.

How Traffic Is Forwarded When AZ Affinity Fails

If the failover threshold is met, AZ affinity fails. In this case, traffic will be distributed based on how you set Forward Traffic To.

If your service requires high availability, you are advised to select Healthy backend servers in all AZs.

Ensure that traffic can be forwarded in the way as you wish regardless of whether AZ affinity fails.

Table 2 How traffic is forwarded when AZ affinity fails

Forward Traffic To

Description

Healthy backend servers in all AZs (recommended)

The load balancer will forward requests across healthy backend servers in all AZs.

Healthy backend servers in other AZs

The load balancer will forward requests across healthy backend servers in different AZs from the load balancer.

All backend servers in the AZ of the load balancer

The load balancer will forward requests across all backend servers in the same AZ as the load balancer, even if some servers are unhealthy.

All backend servers in all AZs

The load balancer will forward requests across all backend servers in all AZs, even if some servers are unhealthy.

If AZ affinity fails, the load balancer can forward requests across healthy backend servers in all AZs.

Figure 2 Distributing traffic across healthy backend servers in all AZs

If AZ affinity fails, the load balancer can forward requests across healthy backend servers in different AZs from the load balancer.

Figure 3 Distributing traffic across healthy backend servers in different AZs from the load balancer

The load balancer will forward requests across all backend servers in the same AZs as the load balancer, even if some servers are unhealthy.

Figure 4 Distributing traffic across all backend servers in the AZ of the load balancer

If AZ affinity fails, the load balancer can forward requests across all backend servers in all AZs, even if some servers are unhealthy.

Figure 5 Distributing traffic across all backend servers in all AZs

Configuring AZ Affinity

  1. Go to the backend server group list page.
  2. On the Backend Server Groups page, locate the backend server group and click Edit in the Operation column.
  3. In the Modify Backend Server Group dialog box, enable or disable AZ Affinity.

    Configure Failover Threshold and Forward Traffic To.

  4. Click OK.