Hello!
I would like to build a proxy for galera cluster which will be switch
incoming connections between two servers.
Both servers are equal - there is no master or slave. However, all
connections must be redirected to the single server and when it goes down,
they must be switched to the second one. If the first server goes up, the
connections must remain to another server (which accepted connections when
the first server was offline).
I found in HAProxy so called "stick tables" but unfortunately, I couldn't
understand how to implement eternal sticky sessions - I can only specify
24d (I suspect that this is INT_MAX) as maximum value for expiration
parameter for stick-table.
And the second question - what rule should I create to achieve the behavior
described above? I tried to use "stick on dst_port" - seems it works but
I'm not sure. I chose "dst_port" because it is always the same for all
client connections.
And the third question - does it make a difference what type of balance
policy is used? For my config below, stickiness seems to work, however my
understanding is that the type of balance policy shouldn't play a role when
choosing server (because I've created stick-table).
However, if I change 'leastconn' to 'roundrobin', stickiness will disappear
in my environment.
Main config is:
listen galera 192.168.77.77:7777
balance leastconn
stick-table type ip size 1k expire 24d
stick on dst_port
option tcpka
option httpchk
mode tcp
server node0 192.168.77.70:3306 check port 50005
server node1 192.168.77.71:3306 check port 50005