RabbitMQ 主题交换:1 个交换 vs 多个交换 [英] RabbitMQ Topic exchanges: 1 Exchange vs Many Exchanges

查看:36
本文介绍了RabbitMQ 主题交换:1 个交换 vs 多个交换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个场景,我需要执行一系列流程,每个步骤都在独立的应用程序中完成和扩展.我正在使用主题交换进行所有交换.当前的拓扑是这样的:

I have a scenario where I have a series of processes I need to perform, each step is done and scaled in independent applications. I am using topic exchanges for all exchanges. Current topology is something like this:

P -> X -> Q -> C/P -> X -> Q -> C

P -> X -> Q -> C/P -> X -> Q -> C

我们正在版本控制"我们的队列以处理影响消息结构的可能的需求变化.绑定可能如下所示:

We are "versioning" our queues to deal with probable requirements changes effecting message structure. Bindings might look something like this:

step1.exchange 与 step1.v1.queue 绑定,key 为 step1.v1

step1.exchange bound to step1.v1.queue with binding key step1.v1

step1.exchange 绑定到 step1.v2.queue,key 为 step1.v2

step1.exchange bound to step1.v2.queue with binding key step1.v2

还有其他与版本无关的绑定模式也使主题交换成为适当的选择.然而,我们可以只使用一个交换来完成同样的事情.

There are other binding patterns that are not version related that also make topical exchanges the appropriate choice. However we could get away with only using one exchange to accomplish the same thing.

TLDR:当您的用例可以以任何一种方式工作时,使用多个主题交换而不是一个主题交换是否有好处?

推荐答案

我只是为你复制一些关键片段.
https://spring.io/blog/2011/04/01/routing-topology-for-performance-and-scalability-with-rabbitmq/

I simply copy some key fragments for you.
https://spring.io/blog/2011/04/01/routing-topologies-for-performance-and-scalability-with-rabbitmq/

  • 如果应用程序图中的路由键域有限,那么许多扇出交换可能是合适的(每个路由键的交换映射为 1:1)

  • If you have a finite domain of routing keys in an application’s graph then many fanout exchanges might be the right fit (1:1 mapping of exchange per routing key)

如果您有无限数量的路由键,请考虑主题交换

If you have a potentially infinite number of routing keys, consider topic exchanges

对于主题路由,性能随着绑定数量的增加而下降

For topic routing, performance decreases as the number of bindings increase

扇出交换非常快,因为如果绑定到大量更改的队列,它们还没有要处理的路由

Fanout exchanges are very fast because they have no routing to process yet if bound to a large number of queues that changes

直接交换是一种更快的主题交换形式,前提是您不需要通配符

Direct exchanges are a faster form of topic exchanges, provided you do not need the wild card

与具有更多绑定、更少交换和队列的拓扑相比,对 100,000 多个队列的问题进行故障排除可能会很乏味

Troubleshooting problems across 100,000+ queues could be tedious versus a topology with more bindings, fewer exchanges and queues

大量的交换和队列占用更多的内存,这可能很重要,但这确实取决于

A very high number of exchanges and queues take up more memory which may be significant but this really depends

从 2011 年 3 月 23 日发布的 RabbitMQ 2.4.0 开始,可以使用新的主题路由算法优化,峰值速度比之前的主题算法快 60 倍.因此,一个建议是减少交换和队列,并增加路由,因为现在增加的时间最小

As of RabbitMQ 2.4.0, released March 23, 2011, a new topic routing algorithm optimization is available that is 60 times faster at peak than the previous topic algorithm. Due to this, one recommendation is to go for less exchanges and queues, and more routing because the time increase is now minimal

这篇关于RabbitMQ 主题交换:1 个交换 vs 多个交换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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