One backend stop when the second one is offline

Hi.

I’m trying to use HAProxy with 2 backend servers (http) and it’s working almost fine. The problem is: when I shutdown the second server, the first one also stoped working…and just after some seconds (about 40s) the first server go back to online state. Why?

Server A -> HAproxy (port 80) and apache (port 8090)
Server B -> HAProxy (port 80) and apache (port 8090)

There’s an floating IP that floats on both servers…but the servers has a fixed IP. I use these fixed IP’s on HA proxy configuration.
This is my configuration:

global
    log         127.0.0.1 local2

    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000
    user        haproxy
    group       haproxy
    daemon
    tune.ssl.default-dh-param   2048
    stats socket /var/lib/haproxy/stats mode 666 level user

defaults
    mode                    http
    stats                   enable
    stats auth              sti:xxxx
    stats                   hide-version
    stats refresh           3s
    stats uri               /hastats
    log                     global
    option                  httplog
    option                  dontlognull
    option http-server-close
    option forwardfor       except 127.0.0.0/8
    option                  redispatch
    retries                 3
    timeout http-request    10s
    timeout queue           1m
    timeout connect         10s
    timeout client          1m
    timeout server          1m
    timeout http-keep-alive 10s
    timeout check           10s
    maxconn                 3000
    balance                 roundrobin
    option httpclose
    option forwardfor
    option httpchk GET / HTTP/1.1\r\nHost:\ localhost
    timeout connect 3000ms
    timeout server 50000ms
    timeout client 50000ms

	
frontend HA-HTTP
        bind *:80
        bind *:443 ssl crt /etc/haproxy/ssl/combinado.pem no-sslv3
        bind ipv6@:80
        bind ipv6@:443 ssl crt /etc/haproxy/ssl/combinado.pem no-sslv3
        maxconn 3000
        default_backend WWW-Servers

backend WWW-Servers
        server megan1 143.107.X.Y:8090 cookie HAP check
        server megan2 143.107.Y.X:8090 cookie HAP check
        balance roundrobin


Tks!

Whats in the logs? You should see backends going down, sessions failing, etc.

Apr 28 08:39:18 143.107.X.Y haproxy[9627]: Server WWW-Servers/megan2 is DOWN, reason: Layer4 timeout, check duration: 2001ms. 1 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
# Here, server A (which still online) turns yellow on HAStats......
Apr 28 08:39:19 143.107.X.Y haproxy[9627]: 143.107.A.FLOATING:49226 [28/Apr/2016:08:39:19.701] HA-HTTP HA-HTTP/<STATS> 0/0/0/0/0 200 14319 - - LR-- 2/2/0/0/0 0/0 "GET /hastats HTTP/1.1"
Apr 28 08:39:22 143.107.X.Y haproxy[9627]: 143.107.A.FLOATING:49232 [28/Apr/2016:08:39:22.781] HA-HTTP HA-HTTP/<STATS> 0/0/0/0/0 200 14325 - - LR-- 2/2/0/0/0 0/0 "GET /hastats HTTP/1.1"
Apr 28 08:39:25 143.107.X.Y haproxy[9627]: 143.107.A.FLOATING:49236 [28/Apr/2016:08:39:25.872] HA-HTTP HA-HTTP/<STATS> 0/0/0/0/0 200 14331 - - LR-- 2/2/0/0/0 0/0 "GET /hastats HTTP/1.1"
Apr 28 08:39:28 143.107.X.Y haproxy[9627]: 143.107.A.FLOATING:49243 [28/Apr/2016:08:39:28.962] HA-HTTP HA-HTTP/<STATS> 0/0/0/0/0 200 14333 - - LR-- 2/2/0/0/0 0/0 "GET /hastats HTTP/1.1"
Apr 28 08:39:32 143.107.X.Y haproxy[9627]: 143.107.A.FLOATING:49248 [28/Apr/2016:08:39:32.048] HA-HTTP HA-HTTP/<STATS> 0/0/0/0/1 200 14331 - - LR-- 2/2/0/0/0 0/0 "GET /hastats HTTP/1.1"
Apr 28 08:39:35 143.107.X.Y haproxy[9627]: 143.107.A.FLOATING:49253 [28/Apr/2016:08:39:35.141] HA-HTTP HA-HTTP/<STATS> 0/0/0/0/0 200 14334 - - LR-- 2/2/0/0/0 0/0 "GET /hastats HTTP/1.1"
Apr 28 08:39:38 143.107.X.Y haproxy[9627]: 143.107.A.FLOATING:49258 [28/Apr/2016:08:39:38.235] HA-HTTP HA-HTTP/<STATS> 0/0/0/0/0 200 14334 - - LR-- 2/2/0/0/0 0/0 "GET /hastats HTTP/1.1"
Apr 28 08:39:41 143.107.X.Y haproxy[9627]: 143.107.A.FLOATING:49263 [28/Apr/2016:08:39:41.315] HA-HTTP HA-HTTP/<STATS> 0/0/0/0/1 200 14336 - - LR-- 2/2/0/0/0 0/0 "GET /hastats HTTP/1.1"
Apr 28 08:39:44 143.107.X.Y haproxy[9627]: 143.107.A.FLOATING:49268 [28/Apr/2016:08:39:44.375] HA-HTTP HA-HTTP/<STATS> 0/0/0/0/1 200 14338 - - LR-- 2/2/0/0/0 0/0 "GET /hastats HTTP/1.1"
Apr 28 08:39:45 143.107.X.Y haproxy[9627]: Server WWW-Servers/megan1 is DOWN, reason: Layer7 timeout, check duration: 10001ms. 0 active and 0 backup servers left. 2 sessions active, 0 requeued, 0 remaining in queue.
Apr 28 08:39:45 143.107.X.Y haproxy[9627]: backend WWW-Servers has no server available!
# Both servers offline! But Server A still oline
# After about 40 seconds, server A go back online

server A is relying on server B for some things and fails when you shutdown server B. You can see that it fails because of a layer 7 problem, so very likely there is a backend (of the server, not the proxy) problem here.

Please share those outputs when the issue occurs and when everything is fine (its simulates the haproxy health check):

curl -v -H "Host: localhost" http://143.107.X.Y:8090/
curl -v -H "Host: localhost" http://143.107.Y.X:8090/

Yep, that’s true. Actually, apache is stopping when server B comes down. I’m using GlusterFS to share WWW folder between 2 servers and for some reason apache is restarting when gluster lost connection with the second server…
They come back after 42 seconds (timeout of gluster), but I don’t knwo why this is happening.