How to perform a load balance between DNS records
You can use an Edge DNS zone to create multiple records and perform a DNS load balance. Assigning different weights to each record for the same zone helps distribute incoming network traffic, ensuring optimal resource utilization and preventing overload on a single server.
In this guide, you’ll learn an example using a record type A
, which accepts values of IPv4 address format.
- Access Azion Console > Edge DNS.
- Choose the zone in which you want to add records from the list or create a zone.
- Select the Records tab.
- Click the + Record button.
- In Name, provide the new record’s name as a subdomain.
- In Type, select the type of record
A
. - In Value, add the items for the DNS response to the registered record in IPv4 address format. Example:
192.111.0.1
. - In TTL (seconds), choose the time, in seconds, that a response can be cached on a resolver server. Maximum value:
2147483647
. - In Policy, select Weighted.
- In Weight, specify the weight for the record, considering that you’ll create other records for the same zone with different weights. Accepts values from
0
to255
. - In Description (optional), you can add a short text that differentiates the records you’ll create for the load balance. Accepts up to 45 characters.
- In Weight, specify the weight for the record, considering that you’ll create other records for the same zone with different weights. Accepts values from
- Click the Save button.
- Repeat steps 4 to 10 to create the other balanced DNS records needed while observing Edge DNS limits, always using the same Name and setting the desired addresses in Value and weights for each record in Weight.
If you add 3 records, you can, for example, specify a weight of 50 for the first record, 20 for the second record, and 30 for the third record.
- Access Real-Time Manager (RTM) > Edge DNS.
- Choose the zone in which you want to add records from the list or create a zone.
- Select the Records tab.
- Click the Add Record button.
- In Name, provide the new record’s name as a subdomain.
- In Type, select the type of record
A
. - In Value, add the items for the DNS response to the registered record in IPv4 address format. Example:
192.111.0.1
. - In TTL (seconds), choose the time, in seconds, that a response can be cached on a resolver server. Maximum value:
2147483647
. - In Policy, select Weighted.
- In Weight, specify the weight for the record, considering that you’ll create other records for the same zone with different weights. Accepts values from
0
to255
. - In Description (optional), you can add a short text that differentiates the records you’ll create for the load balance. Accepts up to 45 characters.
- In Weight, specify the weight for the record, considering that you’ll create other records for the same zone with different weights. Accepts values from
- Click the Save button.
- Repeat steps 4 to 10 to create the other balanced DNS records needed while observing Edge DNS limits, always using the same Name and setting the desired addresses in Value and weights for each record in Weight.
If you add 3 records, you can, for example, specify a weight of 50 for the first record, 20 for the second record, and 30 for the third record.
- Run the following
GET
request in your terminal, replacing[TOKEN VALUE]
with your personal token to retrieve your<hosted_zone_id>
:
- You’ll receive a response with all your existing zones. Copy the value of the
<id>
that you want to use. - Run the following
POST
request, replacing[TOKEN VALUE]
with your personal token and the<hosted_zone_id>
value you copied:
- You’ll receive a response similar to this:
Wait a few minutes for the changes to propagate and your records will be created in the hosted zone you chose.
- Repeat the steps to create the other balanced DNS records needed while observing Edge DNS limits, always using the same
entry
and setting the desired addresses in theanswers_list
parameter and weights for each record in theweight
parameter.
Testing your balanced record
After configuring your balanced record, you can test and see if it’s working via terminal commands:
- Run
dig +short [your balanced hostname]
a couple of times in a row.- You’ll see the address list vary based on the record selected by the Edge DNS load balancer each time.
- The response will be similar to: