Using haproxy, I want:
- A pool of 'main' servers and 'backup' servers, though they don't necessarily have to be in separate pools.
- Each backend has a low 'maxconn' (in this case 1)
- Clients should not wait in a queue. If there are no immediately available servers in the 'main' pool they should be shunted to the 'backup' pool without delay.
Right now I have one backend, 'main' servers have an absurdly high weighting and it 'works'.
acl use_backend
+ connslots
is along the right lines but without the patch in my own answer it isn't perfect.
Bonus points for not requiring a modified haproxy binary.
Best Answer
The correct way is to add an ACL in the frontend which checks the amount of connections on the server, and then makes a decision based on that.
The config below will check the "monitor_conns" frontend and if there are 500 or more connections, they will be sent to the "backups" backend, otherwise they'll go to the "regular" backend.
Here's an untested example:
It's just an example, but it should give you an idea on how to proceed.