Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Load-Distribution in RabbitMQ cluster?

Hi I create three RabbitMQ servers running in cluster on EC2

I want to scale out RabbitMQ cluster base on CPU utilization but when I publish message only one server utilizes CPU and other RabbitMQ-server not utilize CPU

so how can i distribute the load across the RabbitMQ cluster

like image 604
jayesh Avatar asked May 05 '12 12:05

jayesh


2 Answers

RabbitMQ clusters are designed to improve scalability, but the system is not completely automatic.

When you declare a queue on a node in a cluster, the queue is only created on that one node. So, if you have one queue, regardless to which node you publish, the message will end up on the node where the queue resides.

To properly use RabbitMQ clusters, you need to make sure you do the following things:

  • have multiple queues distributed across the nodes, such that work is distributed somewhat evenly,
  • connect your clients to different nodes (otherwise, you might end up funneling all messages through one node), and
  • if you can, try to have publishers/consumers connect to the node which holds the queue they're using (in order to minimize message transfers within the cluster).

Alternatively, have a look at High Availability Queues. They're like normal queues, but the queue contents are mirrored across several nodes. So, in your case, you would publish to one node, RabbitMQ will mirror the publishes to the other node, and consumers will be able to connect to either node without worrying about bogging down the cluster with internal transfers.

like image 56
scvalex Avatar answered Sep 19 '22 23:09

scvalex


That is not really true. Check out the documentation on that subject.

Messages published to the queue are replicated to all mirrors. Consumers are connected to the master regardless of which node they connect to, with mirrors dropping messages that have been acknowledged at the master. Queue mirroring therefore enhances availability, but does not distribute load across nodes (all participating nodes each do all the work).

like image 31
overthetop Avatar answered Sep 19 '22 23:09

overthetop