HAPROXY, The easy load balancer

Load balancing the easy way, with haproxy. I use this all the time with docker. This example will balance 53, across 6 DNS backends. To tweak for your use, you can change the stats port, username and password, and backend servers to your setup.

port 1936 will show the cluster health page. port 53 will round-robin balance across the 6 hosts, and will also pull them out if not healthy, adding them back once health checks pass!

global  
        log 127.0.0.1   local0
        log 127.0.0.1   local1 notice
        maxconn 4096
        chroot /var/lib/haproxy
        user haproxy
        group haproxy
        daemon

defaults  
        log     global
        mode    http
        option  httplog
        option  dontlognull
        option redispatch
        retries 3
        maxconn 2000
        contimeout      5000
        clitimeout      50000
        srvtimeout      50000

listen stats :1936  
        balance
        mode http
        stats enable
        stats auth username:password


listen myservice :53  
        mode tcp
        option tcplog
        balance roundrobin

        server dns0 192.168.10.1:53 check
        server dns1 192.168.10.2:53 check
        server dns2 192.168.10.3:53 check
        server dns3 192.168.10.4:53 check
        server dns4 192.168.20.5:53 check
        server dns5 192.168.20.6:53 check