Help Center/ Domain Name Service/ FAQs/ Public Zones/ Configuring Weighted Routing
Updated on 2025-08-15 GMT+08:00

Configuring Weighted Routing

Scenarios

A large website is generally deployed on multiple servers. To balance the load of each server, you can use weights to control the proportion of requests to each server.

The DNS service allows you to set weights to record sets to route the requests to different servers based on the specified weights. If the weight of a record set is set to 0, no result will be returned.

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

For example, you have a website deployed on three servers. The domain name of your website is example.com, and the IP addresses of the three servers are 198.xx.xx.100, 198.xx.xx.101, and 198.xx.xx.102.

  • If you add an A record set and set its value to the three IP addresses, with no weights set to the IP addresses, requests are randomly routed to an IP address.

    For details, see How Is a Domain Name Resolved When a Record Set Has Multiple Values?

  • You add three A record sets, with each having an IP address as its value.

    In this case, you can set different weights for the three record sets. In this way, requests are routed to each server based on the specified weight.

Weighted routing can better distribute requests and balance server load. You can perform the operations provided in this section to set the weights for record sets of public zones.

Constraints

Explicit and implicit URL record sets do not support weight configuration.

Preparations

There are three web servers. Three A record sets are required, with the value of each set to the IP address of a web server. You can set different weights to control the proportion of requests to each server.

Table 1 Weight setting plans

Plan

Domain Name

Record Set Type

Line

Value

Weight

Description

1

example.com

A

Default

198.xx.xx.100

1

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

198.xx.xx.101

1

198.xx.xx.102

1

2

example.com

A

Default

198.xx.xx.100

2

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

For example, if there are six requests, two are routed to the server whose IP address is 198.xx.xx.100, three are routed to the server whose IP address is 198.xx.xx.101, and one is routed to the server whose IP address is 198.xx.xx.102.

198.xx.xx.101

3

198.xx.xx.102

1

Prerequisites

The domain name of the website has been hosted on the DNS service.

Procedure

The following describes how to add three A record sets to domain name example.com, and the weight ratio of the three record sets is 1:1:1.

  1. Go to the Public Zones page.
  2. On the Public Zones page, click the domain name (example.com) of the public zone.
  3. Click Add Record Set.
  4. Configure the parameters as follows:
    • Type: Retain the default setting A – Map domains to IPv4 addresses.
    • Name: Leave this parameter blank. This is a record set for domain name example.com.
    • Line: Select Default.
    • Value: Set it to 198.xx.xx.100, the IP address of the first website server.
    • Advanced Settings > Weight: Set it to 1.
  5. Click OK.
  6. Repeat 3 to 5 to add the second and third record sets.

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

    Requests will be evenly distributed to the three servers.