We've 2 active hosts for load balancing using haproxy. Haproxy is running on both the hosts. Due to maintenance we need to stop services on Host 1. During the maintenance window we want haproxy instance to stop sending traffic to host 1 and send all requests to Host 2.
Purpose: No outage during server maintenance.
Current behaviour: When service goes down on Host 1. Traffic is still sent to both Host 1 and 2. Since the backend services are down on Host 1, request times out and it is then Haproxy stops sending requests to Host 1. After the event of first failure all traffic if being sent to Host 2 and processed normally.
Is there a way to avoid losing this 1 transaction ( the first failure on Host 1) ? I read about enabling and disabling backend servers using socket file which needs socat or netcat. Haven't tested it but looking solution with haproxy configuration to resolve this.
Backend definition in haproxy config
backend myBackend balance leastconn option httpchk HEAD / default-server inter 5s fastinter 1s downinter 10s fall 2 rise 2 timeout server 20s server s1 ActiveHost1:port check maxconn 10 server s2 ActiveHost2:port check maxconn 10 server s3 standByHost1:port check maxconn 10 backup server s4 standByHost1:port check maxconn 10 backup