Dynamic HAProxy configuration

haproxyload balancing

I try to figure out a way to dynamically manage the loadbalancer configuration.

I want to add and remove "service nodes" depending on the overall system load.

My research so far revealed "Thalassa" https://github.com/PearsonEducation/thalassa/blob/master/README.md which uses Node.JS + Seaport to manage clients and then updates the HA-Proxy configuration

Still I am not convinced if Thalassa is stable enough to be used in productive systems. Are there usable alternatives out there which offer the same features ?

Best Answer

If you authorize your stats socket, you can send commands to it.

From the 1.4 documentation

disable server <backend>/<server>

Mark the server DOWN for maintenance. In this mode, no more checks will be performed on the server until it leaves maintenance. If the server is tracked by other servers, those servers will be set to DOWN during the maintenance.

In the statistics page, a server DOWN for maintenance will appear with a "MAINT" status, its tracking servers with the "MAINT(via)" one.

Both the backend and the server may be specified either by their name or by their numeric ID, prefixed with a sharp ('#').

This command is restricted and can only be issued on sockets configured for level "admin".

You can use this to effectively add and remove servers from active service.

Barring that, you can use option httpchk and block the check requests on the appserver side when a server should leave or join the balancing group. This requires some means to centrally manage that, of course.