How to reconnect to the backend with HAProxy

haproxyhigh-availabilitynetworking

I'm new in working with HAProxy.
I couldn't figure out how to make HAProxy to reconnect to backend that was down and started up back again.

I have a configuration of two backend servers. When they are running and I start HAProxy all works OK. The handshake is passed. Then I stop one of the backend and the traffic correctly goes to the server that is keep running. But then, when I start up the stopped server again HAProhy does not recognize that. Only after HAProxy service restart it can again connect.

How to fix this behavior?

Best Answer

You can use HAProxy backend health checking mechanism:

backend farm1
   server s1 192.168.1.10:80 check
   server s2 192.168.1.11:80 check

More info: http://cbonte.github.io/haproxy-dconv/configuration-1.5.html#check