i run haproxy 1.6 in our environment for different applications. Former we used a Cisco product. Haproxy has a lot of advantages but there is one thing i could not configure with haproxy or i do not know how to do it.
Lets assume i have a backend configured like this:
backend test_farm mode http option httplog balance leastconn cookie test_farm insert nocache option httpchk /test option allbackups timeout check 10s default-server inter 4s fall 15 rise 6 server host1_server1 host1:24320 check cookie PZ22 server host1_server2 host1:24350 check cookie PZ23 server host1_server3 host1:22250 check cookie PZ24 server host1_server4 host1:22280 check cookie PZ25 server host1_server5 host1:22310 check cookie PZ26 server host1_server6 host1:22340 check cookie PZ27 server host2_server1 host2:24320 check cookie BZ22 backup server host2_server2 host2:24350 check cookie BZ23 backup server host2_server3 host2:22250 check cookie BZ24 backup server host2_server4 host2:22280 check cookie BZ25 backup server host2_server5 host2:22310 check cookie BZ26 backup server host2_server6 host2:22340 check cookie BZ27 backup
All servers have the same application installed. I have several backends with other applications. But each backend serves only one specific app and the number of servers vary. The user must stay at one server as long as it is possible to avoid a relogin. As you can see, i use cookie insertion to stick a user to its first connected server. The application is not capable of using session persistence over all servers.
Haproxy only uses the backup servers, wenn all normal servers are down, but i cannot wait until all servers are down. In this case maybe 4 servers can handle the load, but losing one more will struggle the remaining 3 servers. For several reasons i can't simply loadbalance over all servers on host1 and host2. The backup servers should be with no load under normal conditions. I read through the 1.8 version docu, but this one has not changed and i did not found any new functionality in that direction. On the cisco product you could configure, that, when server1 on host1 goes down, immediately use server1 on host2 in the roundrobin or leastconn algo.
And that is my question, how to configure this behaviour.
I thought/tried on some approaches:
Use nbsrv in an acl and define two or more backend sections to the same servers and adding the backup ones: This one worked, but i lost the session affinity and so the users will be kicked out of the application and need to relogin again. And also i guess the more backends exist using the same servers there are more checks do process which has a load impact i want to avoid.
Define the same config as above but do not use backup keyword. Instead i define a weight of 0 to the backup servers. Then use a script triggered by cron and determine via adminsocket how many servers are alive and increase the weight of the backup servers (also via adminsocket) if two or more normal servers are down. I did not test that one, yet. But you can imagine that this is also not a prefered way.
Get my my very old C knowledge up to date and try to code this behaviour, but you know, i would prefer to stick to the versions provided by the developers who have the far better knowledge how to code.
I hope some have perhaps the same scenario and can give me a hint how to that with bord mediums. Of course i read through everything i found on google, but nothing was related to my scenario.
best regards, kaniggl