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

Configuring Weighted Routing

Scenarios

A large website, API, or online service is typically deployed across multiple servers. To balance the access pressure on each server and improve the overall response efficiency, the load balancing solution is widely used in the industry. Huawei Cloud DNS supports weighted routing (weighted round robin). You can configure weights for record sets to control how traffic is distributed. Compared with random round robin, weighted routing provides more precise traffic distribution and more controllable scheduling.

When your website has multiple servers and each server has an independent IP address, weighted routing can be configured to distribute requests to different servers proportionally.

This section describes how to configure weighted routing for a public zone.

Constraints

  • A public zone has been created on the DNS console for the domain name for which you want to configure weighted routing.
  • Explicit and implicit URL record sets do not support weight configuration.
  • You can configure weights only for record sets in the Normal status.
  • The weight value can be from 0 to 1,000. If the weight value is set to 0 for a record set, the resolution result will not be returned.

Weight Configuration Planning

Suppose your website with the domain name example.com is deployed on three servers. Their IP addresses are 119.xx.xx.100, 119.xx.xx.101, and 119.xx.xx.102.

You can create three A record sets for the domain name and point them to different IP addresses of the three servers. You can configure weights to control the proportion of requests to each server.

Table 1 Weight configuration planning

Plan

Domain Name

Type

Line

Value

Weight

1

example.com

A

Default

119.xx.xx.100

1

119.xx.xx.101

1

119.xx.xx.102

1

2

example.com

A

Default

119.xx.xx.100

2

119.xx.xx.101

3

119.xx.xx.102

1

Procedure

Plan 1 in Table 1 is used as an example here. The three record sets are each assigned a weight of 1.

  1. Go to the Public Zones page.
  2. In the public zone list, click the name of the target zone.
  3. On the Record Sets tab, click Add Record Set.
    Configure parameters as instructed and click OK.
    • Type: Select A.
    • Name: Leave this parameter blank. This is a record set for primary domain name.
    • Line: Select Default.
    • Value: Set it to 119.xx.xx.100, the IP address of the first website server.
    • Advanced Settings > Weight: Set it to 1.
  4. Click OK.
  5. Repeat 3 to 4 to add the second and third record sets.

    Set the record set value to 119.xx.xx.101 and 119.xx.xx.102, respectively.

    Requests will be evenly distributed to the three servers.

Implementation Effect

Plan

Weight

Resolution Result

1

1: 1: 1

Requests are evenly distributed to the three servers (the proportion of requests is 1:1:1).

2

2: 3: 1

Requests are distributed to the three servers in a proportion of 2:3:1.

For example, if the DNS server receives six access requests, the expected return result is as follows:

  • 119.xx.xx.100 is returned twice.
  • 119.xx.xx.101 is returned three times.
  • 119.xx.xx.102 is returned once.

During domain name resolution, the returned result may not always match the configured weights. This deviation is a normal characteristic of DNS weighted routing and does not indicate that the configuration is invalid. Weight routing is a proportion-based random scheduling algorithm, so the actual resolution results only approximate the configured weight ratios when observed over large volumes of requests in long-term statistics. For a small number of test requests, data fluctuation is inevitable. DNS cache at each level (carrier local DNS and local cache of user devices) reuses the same resolution result within the TTL validity period. This makes the IP addresses fixed for a period of time, leading to uneven distribution. The carrier recursive DNS and the browsers may apply their own logic to select what they consider the optimal IP address. External factors such as DNS packet length limit and network hijacking may also affect the final resolution result.

Helpful Links

If there is only one A record set whose value is the IP addresses of multiple servers and weight is not configured, visitors will be directed to one of the IP addresses at random. For details, see Which IP Address Is Returned for the Domain Name If There Are Multiple IP Addresses in a Record Set?