# CARP and surviving a HAProxy failure



## unficyp (Sep 1, 2015)

Hi,
Trying out carp(4) and net/haproxy.
I have 2 nodes sharing a single IP using CARP. On each node iI have HAProxy and Apache running.

HAProxy binds the frontend to this VIP, and the backend to each webserver running on the nodes. Everything works fine, CARP moves the IP, HAProxy takes servers out of round-robin, etc.
Except for one thing:
What to do when HAProxy itself fails on the node serving the VIP Address ? How do iI get the CARP Master on the other node?

- Under Linux iI could use keepalived, seems like this port is no longer maintained on FreeBSD.
- A second CARP address, being master on the other node and distribute the 2 VIPs via DNS. Each HAProxy bind its frontends to both VIPs.
- Build own scripts to check if HAProxy is running and force the node to backup if it's not running.
- ?

Any other ideas?

Thanks in advance!
gerald


----------



## SirDice (Sep 2, 2015)

I have built a similar setup for a client. The client was already using sysutils/monit and I made use of it. Monit checks various things, including if HAProxy is still running and accessible. If it isn't it'll use CARP to failover to the other node. I have also added a couple devd(8) events that trigger on CARP going up/down. When it goes up the script check to see if HAProxy is running and starts it if it isn't.


----------



## unficyp (Sep 2, 2015)

sysutils/monit looks promising. 

Thanks for the advice!


----------

