在RabbitMQ中,哪个更昂贵,每个交换有多个队列,还是每个交换有多个交换而每个队列较少? [英] In RabbitMQ which is more expensive, multiple queues per exchange, or multiple exchanges and less queues per each?

查看:306
本文介绍了在RabbitMQ中,哪个更昂贵,每个交换有多个队列,还是每个交换有多个交换而每个队列较少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我们决定在迁移到微服务体系结构中将RabbitMQ用作消息/事件总线,但是对于什么是最好的排队方法,我们找不到确切的答案,我们有两种选择配合:

So we decided to go with RabbitMQ as a message/event bus in our migration to micro-services architecture, but we couldn't find a definite answer on what is the best way of putting our queues, we have two options to go with:

  1. 一个主要的交换将是扇出交换,它将依次将消息散发到主队列以进行日志记录和其他用途;另一个子交换将是主题交换并将消息路由到每个所需的队列使用消息路由密钥.我们期望子交换后面的队列数量可以达到一定数量.可以通过以下图表对此进行说明:

  1. One main exchange which will be a Fanout exchange, which in turn will fan messages out to a main queue for logging and other purposes and another sub exchange which will be a topic exchange and route the messages to each desired queue using the message routing key. We expect the number of queues behind the sub-exchange to be some how a large number. This can be explained by this graph:

一个主交换,将是一个主题交换,还有一个主队列使用#"路由键绑定到该交换.该主交换机还将处理到其他子交换机的主路由,因此路由键可能是"agreements.#","assignments.#","messages.#",这些密钥随后用于绑定多个主题子交换,每个交换处理子路由,因此一个子交换可能正在处理所有分配",并且绑定到该交换的队列可能会被路由键(例如"assignments.accepted","assignments.deleted")绑定...在这种情况下,我们觉得每个交易所的队列数量将减少,它们将以某种方式在交易所之间分配. 那么,这些方案中哪一个可能是最好的方法?使用RabbitMQ更快,开销更少.

One main exchange, which will be a Topic exchange, with still one main queue bound to that exchange using "#" routing key. That main exchange will also handles main routing to other sub exchanges, so routing keys might be "agreements.#", "assignments.#", "messages.#", which are then used to bind multiple topic sub-exchanges, each will handle sub routing, so one sub exchange might be handling all "assignments" and queues bound to that exchange could be bound by routing keys like "assignments.accepted", "assignments.deleted"...In this scenario, we feel like the huge number of queues will be less per exchange, they will be somehow distributed between exchanges. So, which of these scenarios could be the best approach? Faster on RabbitMQ, less overhead.

请记住,所有队列,交换和绑定都将通过将要发布或订阅的服务即时完成.

Taking in mind, all queues, exchanges and bindings will be done on the fly from the service which will be either publishing or subscribing.

推荐答案

您可以在本主题中找到一些解释:

You can find some explanation in this topic: RabbitMQ Topic exchanges: 1 Exchange vs Many Exchanges

我以与案例2所示非常相似的方式使用RabbitMQ,因为我发现了与本文所述相同的好处: https://skillachie.com/2014/06/27/rabbitmq-exchange-to-exchange-bindings-ampq/

I am using RabbitMQ in a very similar way that you showed in the case 2, as I found the same benefits as described in this article: https://skillachie.com/2014/06/27/rabbitmq-exchange-to-exchange-bindings-ampq/

就可以设计的拓扑而言,Exchange到Exchange的绑定要灵活得多,从而可以促进去耦和交换.减少装订流失

Exchange-to-exchange bindings are much more flexible in terms of the topology that you can design, promotes decoupling & reduce binding churn

据说交换交换绑定的重量很轻,因此有助于提高性能*

Exchange-to-exchange bindings are said to be very light weight and as a result help to increase performance *

根据我自己从交换到交换的经验,案例2很好,它将允许以非常快速的方式创建/更改消息流拓扑.

Based in my own experience with exchange-to-exchange, the case 2 is great and it will allows to create/change messages flow topologies in a very fast way.

这篇关于在RabbitMQ中,哪个更昂贵,每个交换有多个队列,还是每个交换有多个交换而每个队列较少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆