Search code examples
rabbitmqmessage-queueamqp

Any advantage using different Exchanges in RabbitMQ?


Is there any difference between using the default (direct) exchange than creating a custom direct exchange for each queue?

(default exchange) -> queue1
(default exchange) -> queue2

vs.

queue1_direct_exchange -> queue1
queue2_direct_exchange -> queue2

In the RabbitMQ dashboard I can see that if I use the default exchange for every queue it has more messages rate so I'm wondering if using different exchanges would increase the performance of message dispatching...

Thanks in advance!


Solution

  • There is no significant performance improvement in using the default direct exchange vs other exchange types, off-hand. The performance differences that you will see depend on how much memory you have on the server, how many queues are receiving a single message, whether or not you are persisting messages to disk, and other factors.

    In general, using the default direct exchange should be avoided. It sounds easy off-hand, but you end up with the design of your queueing system set up backwards, where the message publisher knows which queue should receive the message.

    This is a mistake I made when I first started working with RabbitMQ and it ended up confusing me and causing problems. I didn't know why i needed an exchange, or what the purpose of the routing key was.

    I wrote more about this, here: http://derickbailey.com/2014/11/14/understanding-the-relationship-between-rabbitmq-exchanges-queues-and-bindings/