HAProxy ALOHA Documentation 14.0

Datacenter failover

While you can use geolocation-based load balancing to route traffic to the datacenter nearest to the client, you can also use HAProxy ALOHA for basic failover and failback between datacenters without the geolocation component. If a critical resource fails and service is disrupted, traffic is automatically redirected to healthy datacenters. This minimizes impact and avoids intervention.

https://cdn.haproxy.com/documentation/aloha/latest/assets/gslb-failover-1b172ab7cb57dd8d4feb18b685ef9be9b3b24d45f4983f0c3d1875fb500fbcb1.png

Normal operation

Failover

I

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

A

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

II

HAProxy ALOHA returns the IP address of the first datacenter on the list since it is up and running.

B

HAProxy ALOHA returns the IP address of the next healthy datacenter on the list.

III

The client is directed to the first datacenter on the list.

C

The client is directed to the next healthy datacenter on the list.

  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 mydomain.com
      ttl 10
    
      # ORIGIN records
      record @ SOA ns1.mydomain.com hostmaster.mydomain.com 1 86400 3600 3600 3600 60
      record @ NS  ns1.mydomain.com
      record @ ttl 3600 MX 100  mail1.mydomain.com
    
      # static records
      record ns1   ttl 10 A 10.0.0.1
      record mail1 ttl 10 A 10.0.0.2
  5. Add a new list record directive to the zone section. This type of record specifies a list of space-separated answer-list names. Essentially, you are specifying datacenters in order of preference, with fallback datacenters following primary datacenters.

    The list record www enumerates two answer-list sections, DC1 and DC2, where DC1 is the primary datacenter and DC2 is the fallback. You could list additional fallback datacenters too.

    zone mydomain.com
      ttl 10
    
      # ORIGIN records
      record @ SOA ns1.mydomain.com hostmaster.mydomain.com 1 86400 3600 3600 3600 60
      record @ NS  ns1.mydomain.com
      record @ ttl 3600 MX 100  mail1.mydomain.com
    
      # static records
      record ns1   ttl 10 A 10.0.0.1
      record mail1 ttl 10 A 10.0.0.2
    
      # dynamic records - DC1 is primary, DC2 is a fallback
      record www ttl 30 list DC1 DC2
  6. Create answer-list sections that match the names you listed on the list record in the zone section.

    We define two answer-list sections named DC1 and DC2. These return DNS records to the client for different datacenters.

    zone mydomain.com
      ttl 10
    
      # ORIGIN records
      record @ SOA ns1.mydomain.com hostmaster.mydomain.com 1 86400 3600 3600 3600 60
      record @ NS  ns1.mydomain.com
      record @ ttl 3600 MX 100  mail1.mydomain.com
    
      # static records
      record ns1   ttl 10 A 10.0.0.1
      record mail1 ttl 10 A 10.0.0.2
    
      # dynamic records
      record www ttl 30 list DC1 DC2
    
    answer-list DC1
      up_threshold 1
      method multi-up
      option httpchk
      http-check connect
      http-check send uri /health.html hdr host www.mydomain.com
      http-check expect status 200,301,302
      answer-record srv1 20.0.0.1
    
    answer-list DC2
      up_threshold 1
      method multi-up
      option httpchk
      http-check connect
      http-check send uri /health.html hdr host www.mydomain.com
      answer-record srv1 30.0.0.1

    The answer-list section directives syntax is as follows.

    Directive

    Description

    up_threshold

    Determines the percentage of servers that must be up. Otherwise, traffic is routed to a different datacenter altogether. A threshold of 1 means that all servers in an answer-list must be healthy for the corresponding datacenter to be regarded as active. If you specify 0.1, then 10% of the total weighted number of servers must be up.

    method

    Determines which IP addresses to return. As with geolocation-based load balancing, you can:

    • return a single IP in a round-robin rotation (single-rr)

    • return multiple addresses in a round-robin rotation (method multi-rr)

    • return all servers that are up (method multi-up)

    • return all servers, even if they are down (method multi-all)

    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, which denote IP addresses assigned to the datacenter.

  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

DNS round-robin load-balancing
HAProxyConf 2022 - Call for papers