HAProxy in a fail-over pair
I quite often come across people looking for advice on setting up HAProxy on a pair of servers, so achieving highly-available load balancing.
A lot of people use heartbeat, which monitors the neighbouring server’s state, and stops and starts any given services accordingly. However heartbeat, isn’t quite the right job for the tool, as Willy Tarreau, HAProxy’s author explains the merits of keepalived.
It is not the best tool for this job, it was designed to build clusters, which is a lot different from having two redundant stateless network equipments.
HAProxy fail-over and stay-over
As I get to use HAProxy more and more, I recently ran into a particular circumstance where I needed to failover traffic from the live server, to the standby server. This is simple to do using the ‘backup‘ option in your haproxy configuration, however I wanted to ensure the service wouldn’t fail-back when the primary server was restored. In essence I needed a fail-over & stay-over setup.
The answer, until a specific feature is added to haproxy, is to set the criteria (i.