HAProxy ALOHA Documentation 14.0

DNS round-robin load-balancing

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

https://cdn.haproxy.com/documentation/aloha/latest/assets/gslb-round-robin-d202c229b47813e3c5b4d71d93ddd59e03b4a97391d07f802a3f526ce68f66a0.png

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. In the Services tab, click gslb setup.

    https://cdn.haproxy.com/documentation/aloha/latest/assets/gslb_setup-5d94fea5c7b1117e1c2b70befe6438884c175a7df4d31f719c0ae5d0d8772359.png
  2. Add a listen directive for each IP address/network port pair at which the GSLB should listen for DNS queries. By default, it listens on all IP addresses (0.0.0.0) at port 53.

  3. To enable the service to start automatically when the appliance boots, delete the no autostart line, click OK and then Close.

  4. In the Services tab, click [advanced mode], then edit the gslb configuration.

    https://cdn.haproxy.com/documentation/aloha/latest/assets/gslb_service_advanced-778c09fbc8cb1d56fc76474de03dd5b9fab9e1e5d72eb2d3dab33a14f488b306.png

    The current configuration displays.

    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
  5. 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.

    The list record www contains one answer-list: dc1.

    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
  6. 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 ALOHA 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.

  7. Save your configuration, close the configuration editor, then apply your changes on the gslb line in the Services tab.

    https://cdn.haproxy.com/documentation/aloha/latest/assets/apply-service-gslb-d3f26a7ad971a89779e3d4ff6a86a323864b35122d4799da6377c04caf4d8d10.png

Next up

Geolocation-based load balancing
HAProxyConf 2022 - Call for papers