Score:0

Set up HAProxy load balancer in docker for a docker RabbitMQ cluster

cn flag

I've set up a 3 node RabbitMQ cluster in docker using the following,

docker run -d --rm --net rabbits `
-v ${PWD}/config/rabbit-1/:/config/ `
-e RABBITMQ_CONFIG_FILE=/config/rabbitmq `
-e RABBITMQ_ERLANG_COOKIE=WIWVHCDTCIUAWANLMQAW `
--hostname rabbit-1 `
--name rabbit-1 `
-p 8081:15672 `
-p 8084:5672 `
rabbitmq:3.8-management

My docker network name is rabbits. I'm struggling to setup a docker HAProxy load balancer for this cluster. I'm a complete novice in both docker and load balancing, so the config file doesn't make much sense to me. The following is my current haproxy.config,

global
        debug
 
defaults
        log     global
        mode    tcp
        timeout connect 5000
        timeout client 50000
        timeout server 50000

frontend main
        bind *:8089
        default_backend app

backend app
        balance roundrobin
        mode http
        server          rabbit-1 172.18.0.2:8084
        server          rabbit-2 172.18.0.3:8085
        server          rabbit-3 172.18.0.4:8086

The 172.18.0.* is my RabbitMQ nodes IP address, I'm not sure if I'm supposed to give the ip address or the network name in the backend app. And I'm not sure about the mode as well. What I'm trying to achieve is have my client 3 node microservice application send/receive messages through amqp://guest:guest@loadbalancer:5672 URL. Please help me out.

jp flag
Use `mode tcp`. You'll need to adjust port in your `amqp://` URL.
cn flag
I'll try updating the mode as tcp. My other doubt is that the docker container ip address. My backend app ip address 172.18.0.2 is from the docker container and I'm not sure if i'm supposed to do the way I've done right now.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.