Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does RabbitMq do round-robin from the exchange to the queues

I am currently evaluating message queue systems and RabbitMq seems like a good candidate, so I'm digging a little more into it.

To give a little context I'm looking to have something like one exchange load balancing the message publishing to multiple queues. I don't want to replicate the messages, so a fanout exchange is not an option.

Also the reason I'm thinking of having multiple queues vs one queue handling the round-robin w/ the consumers, is that I don't want our single point of failure to be at the queue level.

Sounds like I could add some logic on the publisher side to simulate that behavior by editing the routing key and having the appropriate bindings in place. But that's kind of a passive approach that wouldn't take the pace of the message consumption on each queue into account, potentially leading to fill up one queue if the consumer applications for that queue are dead.

I was looking for a more pro-active way from the exchange entity side, that would decide where to send the next message based on each queue size or something of that nature.

I read about Alice and the available RESTful APIs but that seems kind of a heavy duty solution to implement fast routing decisions.

Anyone knows if round-robin between the exchange the queues is feasible w/ RabbitMQ then? Thanks.

like image 785
Lancelot Avatar asked Apr 07 '10 21:04

Lancelot


People also ask

Is RabbitMQ round robin?

By default, RabbitMQ will send each message to the next consumer, in sequence. On average every consumer will get the same number of messages. This way of distributing messages is called round-robin.

How do exchanges work in RabbitMQ?

In actual case, working of RabbitMQ is that producer sends message to “EXCHANGE” and exchange pushes it to multiple queues and workers get message from queues to which it has binded with. Now instead of publishing directly to queue, producer now publish messages to exchange.

How does RabbitMQ queue work?

The user sends a PDF creation request to the web application. The web application (the producer) sends a message to RabbitMQ that includes data from the request such as name and email. An exchange accepts the messages from the producer and routes them to correct message queues for PDF creation.

Can a RabbitMQ queue bind to multiple exchanges?

YES, it can. A queue can have any number of bindings to different exchanges, even multiple bindings to the same exchange with different parameters.


1 Answers

One built in way you can do a form of sharing a form exchange to queues, but not exactly round robin, is Consistent Hashing. rabbitmq_consistent_hash_exchange

How too https://medium.com/@eranda/rabbitmq-x-consistent-hashing-with-wso2-esb-27479b8d1d21

Paper to explain, it puts queues at a weighted distribution on a circle and then by sending random routing key it will send to the closest queue. http://www8.org/w8-papers/2a-webserver/caching/paper2.html

like image 63
tristanbailey Avatar answered Oct 11 '22 22:10

tristanbailey