HAProxy Enterprise Documentation 2.2r1

DNS round-robin load-balancing

You can make GSLB return several IP addresses from healthy datacenters in a round-robin weighted fashion.

First client

Second client

I

A client asks for the IP address associated with the www.example.com domain name.

A

A client asks for the IP address associated with the www.example.com domain name.

II

GSLB returns a healthy IP address from the pool of available addresses.

B

GSLB returns the next healthy IP address from the pool of available addresses, in a round-robin fashion.

III

The client connects to the IP address.

C

The client connects to the IP address.

  1. Edit the example configuration. Ensure the correct information is set in the zone example.com section of your configuration file at /etc/hapee-extras/hapee-gslb.conf, such as your domain name and record entries.

  2. Add a new list record to the zone section. The record section directives syntax is as follows:

    Record type

    Description

    list

    Dynamic record followed by list of space-separated answer-list names.

  3. Create answer-list sections that match the names you listed in the zone section.

    zone example.com
      ttl 10
      # ORIGIN records
      record @ SOA ns1.example.com hostmaster.example.com 1 86400 3600 3600 3600 60
      record @ NS  ns1.example.com
      record @ ttl 3600 MX 100 mail1.example.com
    
      # Static records
      record ns1   ttl 20 A 10.0.0.1
      record mail1 ttl 20 A 10.0.0.2
    
      # Dynamic records
      record www ttl 20 list dc1
    
    answer-list dc1
      method single-rr
      option httpchk
      http-check connect
      http-check send uri /health.html hdr host www.example.com
      answer-record srv1 20.0.0.1 weight 10
      answer-record srv2 20.0.0.2 weight 20

    The answer-list section directives syntax is as follows.

    Directive

    Description

    method

    Set the single-rr parameter.

    option

    Specify httpchk to monitor the health of servers.

    http-check

    Set any relevant health check parameters.

    answer-record

    Enter any number of answer-record directives along with the corresponding IP addresses. Weights determine how often a particular IP address will be returned, with higher weights being chosen more often.

    By specifying method single-rr, HAProxy Enterprise alternates which IP for a datacenter it sends to clients in order to distribute traffic across all servers. In that case, the odds of a server's IP being returned is server weight / sum of all server weights.

  4. Save your configuration, close the configuration editor, then apply your changes. Enable and start the GSLB service.

    $ sudo systemctl restart hapee-extras-gslb

Next up

Enable GSLB failover