How to Set Up DNS Load Balancing on VergeCloud for Efficient Website Traffic Management

Configuring DNS Load Balancing on VergeCloud: Optimize Traffic Distribution for Your Website"

DNS Load Balancer

The VergeCloud DNS Load Balancer allows you to distribute incoming traffic for your domain or subdomains across multiple servers. This distribution can be configured based on the weight of each server, type of response, or the geographic location of the user, providing enhanced reliability and optimal performance.

What is a DNS Load Balancer?

A DNS Load Balancer is a tool that helps in spreading the incoming requests to your domain across multiple servers. This feature enhances redundancy and ensures that no individual server is overloaded, which improves the overall availability and response time of your website.

Steps to Enable DNS Load Balancer

  1. Navigate to the VergeCloud user panel and select the domain where you wish to configure load balancing.
  2. Go to the DNS Records section and create a new A Record.
  3. In the Name field, specify the hostname (subdomain) for which you want to set up load balancing. Use @ for the root domain or enter the specific subdomain name if applicable.
  4. Provide the IP addresses of the servers in the Value field. You can enter multiple IPs to distribute the traffic among those servers.
  5. In the Response Type section, specify whether you want the DNS to respond with a single IP or multiple IP addresses when resolving the domain.
  6. Under Load Balancing Method, select the traffic distribution approach:
    • Round-Robin: Traffic is distributed in a sequential, cyclical manner.
    • Weighted Distribution: Traffic is distributed based on the weight assigned to each server.
  7. Weight Configuration: Assign weight values to each server to define how traffic is divided. The ratio between weights is important, not the specific value. For example, weights of 1 and 2 are equivalent to weights of 10 and 20.
  8. Enable Geographic Load Balancing to distribute traffic based on the user's location. Select the desired country for each IP address.
  9. Click Save to apply the settings.
DNS Load Balancer Record Creation

Creating a Load Balancer Record Using API

You can also configure a load balancer record via VergeCloud's API. Below is an example request that creates a new A Record with load balancing:

  1. curl --location --request POST 'https://api.vergecloud.com/domains/example.com/dns-records' \ --header 'Authorization: Bearer APIKEY' \ --header 'Content-Type: application/json;charset=UTF-8' \ --data-raw '{"type":"A","name":"@","cloud":false,"value":[{"country":"","ip":"192.168.1.1","port":null,"weight":"20"},{"country":"SG","ip":"192.168.1.2","port":null,"weight":"10"},{"country":"AU","ip":"192.168.1.3","port":null,"weight":"50"}],"upstream_https":"default","ip_filter_mode":{"count":"single","geo_filter":"country","order":"weighted"},"ttl":120}'

Understanding Key Fields in Load Balancer Configuration
  • Name Field: Indicates the hostname or subdomain where load balancing should be applied. Use @ for the root domain, or specify the subdomain name.
  • Value Field: Provide the IP addresses of the servers. Multiple IPs allow you to distribute the incoming requests among different servers.
  • Response Type: Specify whether the DNS should return one or more IP addresses when the domain is queried. Returning multiple IPs can improve redundancy.
  • Load Balancing Method: Select the distribution method for the incoming traffic:
    • Round-Robin: Each server is assigned an equal opportunity to handle requests, regardless of the traffic load.
    • Weighted Distribution: Servers receive requests based on their assigned weights, with higher weights indicating a larger share of the traffic.
  • Weight Configuration: Set the weight of each server to determine its share of the traffic. Only the ratio between the weights matters, allowing for flexibility in configuration.
  • Geographic Load Balancing: Assign users to specific servers based on their geographic location to reduce latency and improve user experience.

Testing DNS Load Balancer Configuration

After setting up your DNS Load Balancer, it's essential to verify the configuration. Use the dig command to ensure your DNS records are resolving as expected:

  1. dig A example.com

Sample Test Output

  1. ; <<>> DiG 9.16.1-Ubuntu <<>> A example.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 12345 ;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;example.com. IN A ;; ANSWER SECTION: example.com. 120 IN A 192.168.1.1 example.com. 120 IN A 192.168.1.2 example.com. 120 IN A 192.168.1.3 ;; Query time: 27 msec ;; SERVER: 8.8.8.8#53(8.8.8.8) ;; WHEN: Thu Sep 26 15:10:12 UTC 2024 ;; MSG SIZE rcvd: 100

Considerations for DNS Load Balancer

  • Use weighted distribution to accommodate servers with different capacities, ensuring more powerful servers receive more traffic.
  • Geographic load balancing helps deliver content from the closest server, reducing latency for end users.
  • Allow up to 48 hours for DNS changes, including load balancer configuration, to propagate across the internet.