Bhoomi Zalavadiya
Bhoomi Zalavadiya

Reputation: 689

How to add server dynamically in HA proxy backend?

I am using HA proxy version 1.6.6 for load balancing rabbitmq server, and it works fine but i want to add server dynamically in ha proxy backend in ubuntu using script. can anyone please tell me how can i done it?

Upvotes: 10

Views: 8103

Answers (3)

CᴴᴀZ
CᴴᴀZ

Reputation: 531

HAProxy OSS v1.8 does not include add/remove commands in Runtime API, but you can achieve similar functionality by using ready/disabled state commands.

  • Add server(s) config in haproxy.cfg in disabled state: server-template websrv 1-100 192.168.122.1:8080 check disabled //This adds 100 servers (websrv1...websrv100) in disabled state
  • Enable server (similar to add feature): set server be_template/websrv1 state ready
  • Disable server (similar to remove feature): set server be_template/websrv1 state maint

Address and port can be changed using Runtime API as usual: set server be_template/websrv1 addr 192.168.50.112 port 8000

Reference(s):

  1. https://www.haproxy.com/blog/dynamic-configuration-haproxy-runtime-api/
  2. https://www.haproxy.com/blog/dynamic-scaling-for-microservices-with-runtime-api/

Upvotes: 12

Nic0
Nic0

Reputation: 112

I think there is not this kind of features with HAProxy Open Source.

If you use their ALOHA Load Balancer, there is an API to do this actions here :

https://www.haproxy.com/resources/documentation/

Upvotes: 0

Bohdan Biehov
Bohdan Biehov

Reputation: 431

As far as I know haproxy api ( stats socket ) does not support dynamic adding/removing servers to backend. One of the solution to use consul, the cost - reload service after some change. https://www.hashicorp.com/blog/haproxy-with-consul.html

Upvotes: 0

Related Questions