'Affinity in HAProxy for TCP Load Balancing

I have a Galera cluster with HA Proxy for High Availablity. Due to application constraints I am using single write in multi master environment.

My Problem is as below

  • Primary goes down and connections move to backup server as configured
  • Primary is UP again, HA proxy starts moving connections back to primary but not all. so I ended up with write connection to both Primary and backup server. connection in backup server keep getting released but it takes couple of hours before all connections are only in Primary.

Now my requirement is that I am ok with connections being in any of the 2 but I want it to be in one at a time not in both. Because when I have 2 write nodes, I get to see conflicts.

Do HAProxy has any configuration to keep all connection to a particular server (primary or backup) and change only when that nodes goes down



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source