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.
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 192.168.1.1, 192.168.1.2, and 192.168.1.3.
- 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.
Constraints
You can configure weights for up to 20 record sets of the same domain name and line.
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.
Plan |
Domain Name |
Record Set Type |
Line Type |
Value |
Weight |
Description |
---|---|---|---|---|---|---|
1 |
example.com |
A |
Default |
192.168.1.1 |
1 |
Requests are evenly distributed to three servers (the proportion of requests is 1:1:1). |
192.168.1.2 |
1 |
|||||
192.168.1.3 |
1 |
|||||
2 |
example.com |
A |
Default |
192.168.1.1 |
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 192.168.1.1, three are routed to the server whose IP address is 192.168.1.2, and one is routed to the server whose IP address is 192.168.1.3. |
192.168.1.2 |
3 |
|||||
192.168.1.3 |
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.
- Go to the Public Zones page.
- On the Public Zones page, click the domain name (example.com) of the public zone.
The Record Sets tab is displayed.
- Click Add Record Set.
- Configure the parameters as follows:
- Name: Leave this parameter blank. This is a record set for the domain name, which is example.com.
- Type: Retain the default setting A – Map domains to IPv4 addresses.
- Line Type: Select Default.
- Value: Set it to 192.168.1.1, the IP address of a web server.
- Weight: Set it to 1.
- Click OK.
- Repeat 3 to 5 to add the second and third record sets.
Set the record set value to 192.168.1.2 and 192.168.1.3, respectively.
Requests will be evenly distributed to the three servers.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot