ELMA365 On-Premises > Prepare infrastructure > Load balancer / Configure HAProxy for RabbitMQ

Configure HAProxy for RabbitMQ

Highly available ELMA365 cluster architecture involves the interaction of ELMA365 application microservices with a RabbitMQ message broker cluster. The HAProxy configuration discussed in this article assumes even load balancing of traffic between RabbitMQ cluster nodes.

Example HAProxy configuration for RabbitMQ

This configuration is prepared for load balancing traffic in a RabbitMQ cluster deployed according to the instructions in RabbitMQ cluster.

  • HAProxy evenly balances client connections (AMQP) arriving at haproxy-server.your_domain:5672;
  • HAProxy proxies connections to the RabbitMQ web interface (HTTP-based API) arriving at haproxy-server.your_domain:15672.

Open the haproxy.cfg configuration file for editing using the command:

sudo nano /etc/haproxy/haproxy.cfg

Example configuration for load balancing to the RabbitMQ cluster using HAProxy to add to the haproxy.cfg file:

### RabbitMQ ###
listen rabbitmq
    bind haproxy-server.your_domain:5672
    mode tcp
    balance roundrobin
    server rabbitmq-server1 rabbitmq-server1.your_domain:5672 check inter 2s rise 2 fall 3
    server rabbitmq-server2 rabbitmq-server2.your_domain:5672 check inter 2s rise 2 fall 3
    server rabbitmq-server3 rabbitmq-server3.your_domain:5672 check inter 2s rise 2 fall 3
 
listen rabbitmq_management
    bind haproxy-server.your_domain:15672
    balance source
    server rabbitmq-server1 rabbitmq-server1.your_domain:15672 check inter 2s
    server rabbitmq-server2 rabbitmq-server2.your_domain:15672 check inter 2s
    server rabbitmq-server3 rabbitmq-server3.your_domain:15672 check inter 2s
### RabbitMQ ###

Example of HAProxy configuration with SSL

Restart HAProxy:

sudo systemctl restart haproxy

Found a typo? Highlight the text, press ctrl + enter and notify us