【原创】RabbitMQ 之 Distributed brokers(翻译)

简介:
Distributed RabbitMQ brokers  

AMQP and the other messaging protocols supported by RabbitMQ via plug-ins (e.g. STOMP), are (of course) inherently distributed - it is quite common for applications from multiple machines to connect to a single broker, even across the internet.  
AMQP 协议以及其他的 RabbitMQ 通过插件方式支持的消关协议(例如 STOMP)在本质都是分布式的,因为通过多台机器连接到单个 broker 的应用场景太常见了,即便跨越因特网的连接也是如此。  

Sometimes however it is necessary or desirable to make the RabbitMQ broker itself distributed. There are three ways in which to accomplish that: with clustering, with federation, and using the shovel. This page explains the purpose of each approach.  
然而,有些时候让 RabbitMQ broker 本身具有分布式功能也是非常必要的;目前存在 3 种方式可以达成此目的:基于集群实现,通过 federation 插件实现,以及通过 shovel 插件实现。本节内容针对这几种方式进行解释说明。  

Note that you do not need to pick a single approach - you can connect clusters together with federation, or the shovel, or both.  
需要注意的是,你不是只能使用单一一种方式达成目标,如果你愿意,你可以通过 federation 或/和 shovel 插件连接你的集群;  


Clustering

Clustering connects multiple machines together to form a single logical broker. Communication is via Erlang message-passing, so all nodes in the cluster must have the same Erlang cookie. The network links between machines in a cluster must be reliable, and all machines in the cluster must run the same versions of RabbitMQ and Erlang.  
集群功能   可以将多台机器相互连接形成一个单一的逻辑 broker ;  
集群中的通信方式采用 Erlang 语言自身的消息传递模式,所以集群中的所有节点都必须持有相同的 Erlang cookie 值;  
在同一集群中,各台机器之间的网络连接必须是可靠的;  
集群中的所有机器上必须运行相同版本的 RabbitMQ 和 Erlang ;  

Virtual hosts, exchanges, users, and permissions are automatically mirrored across all nodes in a cluster. Queues may be located on a single node, or mirrored across multiple nodes. A client connecting to any node in a cluster can see all queues in the cluster, even if they are not located on that node.  
vhost, exchange, user 和 permission 等信息会自动复制到集群中的每个节点上;  
queue 稍微特殊一点,你可以认为其位于单独一个节点上,当然,也可以通   镜像队列   方式将 queue 的内容复制到多个节点上;  
连接到集群中的任意节点上的客户端都能够看到属于该集群的全部 queue 信息,即使这些 queue 并不真正位于该节点;  

Typically you would use clustering for high availability and increased throughput, with machines in a single location.  
集群的典型应用场景为需要高可用和增加吞吐量的场合,并且集群中的所有机器位于同一个地点。  

Federation  

Federation allows an exchange or queue on one broker to receive messages published to an exchange or queue on another (the brokers may be individual machines, or clusters). Communication is via AMQP (with optional SSL), so for two exchanges or queues to federate they must be granted appropriate users and permissions.  
Federation 允许从某个 broker 上的 exchange 或 queue 中能够接收到,发向另一个 broker 的 exchange 或 queue 上的消息;  
上面说的 broker 可以是单独的机器,也可以是集群;  
Federation 的实现基于 AMQP 协议(可选增加 SSL),所以成功 federate 两个 exchange 或 queue 的前提是必须设置好适当的 user 和 permission 约束;  

Federated exchanges are connected with one way point-to-point links. By default, messages will only be forwarded over a federation link once, but this can be increased to allow for more complex routing topologies. Some messages may not be forwarded over the link; if a message would not be routed to a queue after reaching the federated exchange, it will not be forwarded in the first place.  
Federated exchange 属于一种单向点对点连接;默认情况下,消息将只能从该 federation link 上转发一次,但是可以增加转发次数以满足更加复杂的路由策略;  
某些消息可能根本不会从该 federation link 上进行转发;  
如果某条消息在到达 federation exchange 后根本不会被路由到 queue 中,那么该消息最初就不会被转发;  

Federated queues are similarly connected with one way point-to-point links. Messages will be moved between federated queues an arbitrary number of times to follow the consumers.  
Federated queue 同样属于一种单向点对点连接;  
消息会在 Federated queue 之间搬移任意多次以 follow 消费者;  

Typically you would use federation to link brokers across the internet for pub/sub messaging and work queueing.  
Federation 的典型应用场景为跨因特网将两个 broker 连接起来,用于消息的 pub/sub 行为,或者用于工作队列模式;  


The Shovel  

Connecting brokers with the shovel is conceptually similar to connecting them with federation. However, the shovel works at a lower level.  
通过 shovel 连接 broker 与通过 federation 连接 broker 在概念上是相似的;   但是 shovel 属于更加底层的应用模型    

Whereas federation aims to provide opinionated distribution of exchanges and queues, the shovel simply consumes messages from a queue on one broker, and forwards them to an exchange on another.  
federation 的设计限制其分布式功能是针对 exchange 和 queue 的;  
而 shovel 的设计只是简单的要求从某个 broker 上的 queue 中消费消息,再转发到另一个 broker 上的 exchange 上;  

Typically you would use the shovel to link brokers across the internet when you need more control than federation provides.  
一般情况下,如果你需要比 federation 所能提供的更多的控制,你就要使用 shovel 来完成跨因特网的 broker 连接了;  

Dynamic shovels can also be useful for moving messages around in an ad-hoc manner on a single broker.  
Dynamic shovel 对于针对同一个 broker 以 ad-hoc 方式搬移消息的场景同样非常有用;  

Summary  

Federation / Shovel
Clustering
Brokers are logically separate and may have different owners.
不同 broker 之间逻辑上是独立的,可能分属不同的 owner ;
A cluster forms a single logical broker.
整个集群构成一个单独的逻辑 broker ;
Brokers can run different versions of RabbitMQ and Erlang.
不同 broker 上可以运行不同版本的 RabbitMQ 和 Erlang ;
Nodes must run the same version of RabbitMQ, and frequently Erlang.
全部节点必须运行相同版本的 RabbitMQ 和 Erlang 版本;
Brokers can be connected via unreliable WAN links. Communication is via AMQP (optionally secured by SSL), requiring appropriate users and permissions to be set up.
broker 之间的连接可以建立在不可靠的 WAN 网上;通信协议采用 AMQP (可选 SSL 加密);需要建立合适的 user 和 permission 设置;
Brokers must be connected via reliable LAN links. Communication is via Erlang internode messaging, requiring a shared Erlang cookie.
broker 之间必须通过可靠的 LAN 网建立连接;通信方式采用 Erlang 的节点内消息发送;要求所有节点共享 Erlang cookie 值;
Brokers can be connected in whatever topology you arrange. Links can be one- or two-way.
broker 之间可以按照任何形式的拓扑结构进行连接;连接可以是单向的或者双向的;
All nodes connect to all other nodes in both directions.
所有节点两两互联,且为双向连接;
Chooses Availability and Partition Tolerance (AP) from the CAP theorem.
基于 CAP 理论中的 AP 实现;
Chooses Consistency and Partition Tolerance (CP) from theCAP theorem.
基于 CAP 理论中的 CP 实现;
Some exchanges in a broker may be federated while some may be local.
broker 中的某些 exchange 可能进行了 federated ,而另外一些可能是本地的;
Clustering is all-or-nothing.
在集群中,所有 fabric 的属性都一致;
A client connecting to any broker can only see queues in that broker.
连接到任意一个 broker 上的客户端只能看到属于该 broker 的 queue 信息;
A client connecting to any node can see queues on all nodes.
连接到集群中的任意节点,都能看到属于集群的所有 queue 信息;




相关实践学习
快速体验阿里云云消息队列RocketMQ版
本实验将带您快速体验使用云消息队列RocketMQ版Serverless系列实例进行获取接入点、创建Topic、创建订阅组、收发消息、查看消息轨迹和仪表盘。
消息队列 MNS 入门课程
1、消息队列MNS简介 本节课介绍消息队列的MNS的基础概念 2、消息队列MNS特性 本节课介绍消息队列的MNS的主要特性 3、MNS的最佳实践及场景应用 本节课介绍消息队列的MNS的最佳实践及场景应用案例 4、手把手系列:消息队列MNS实操讲 本节课介绍消息队列的MNS的实际操作演示 5、动手实验:基于MNS,0基础轻松构建 Web Client 本节课带您一起基于MNS,0基础轻松构建 Web Client
目录
相关文章
|
运维 监控 JavaScript
(ARMS-AIOps)一文教你用Attributor算法实现多维下钻分析
常见的AIOps应用路径为:对监控的各种关键性能指标(KPI)进行实时异常检测;对多维指标进行根源分析,快速下钻到异常维度和元素;基于应用拓扑和实时Trace,实现根因定位;结合CMDB、关联等、构建异常根因上下文,帮助快速修复问题。 作为KPI指标, 往往包含了很多维度和元素,最显而易见的则是对每一个维度的元素都进行实时异常检测。 对于维度组合笛卡尔集数量很长的场景, 该方案的成本则有点难以承受
5940 0
GitHub:如何从GitHub上下载文件(下载单个文件或者下载整个项目文件)之详细攻略(图文教程)
GitHub:如何从GitHub上下载文件(下载单个文件或者下载整个项目文件)之详细攻略(图文教程)
GitHub:如何从GitHub上下载文件(下载单个文件或者下载整个项目文件)之详细攻略(图文教程)
|
消息中间件 存储 NoSQL
RocketMQ实战—6.生产优化及运维方案
本文围绕RocketMQ集群的使用与优化,详细探讨了六个关键问题。首先,介绍了如何通过ACL配置实现RocketMQ集群的权限控制,防止不同团队间误用Topic。其次,讲解了消息轨迹功能的开启与追踪流程,帮助定位和排查问题。接着,分析了百万消息积压的处理方法,包括直接丢弃、扩容消费者或通过新Topic间接扩容等策略。此外,提出了针对RocketMQ集群崩溃的金融级高可用方案,确保消息不丢失。同时,讨论了为RocketMQ增加限流功能的重要性及实现方式,以提升系统稳定性。最后,分享了从Kafka迁移到RocketMQ的双写双读方案,确保数据一致性与平稳过渡。
|
人工智能 文字识别 API
moonshot-v1-vision-preview:月之暗面Kimi推出多模态视觉理解模型,支持图像识别、OCR文字识别、数据提取
moonshot-v1-vision-preview 是月之暗面推出的多模态图片理解模型,具备强大的图像识别、OCR文字识别和数据提取能力,支持API调用,适用于多种应用场景。
2696 6
moonshot-v1-vision-preview:月之暗面Kimi推出多模态视觉理解模型,支持图像识别、OCR文字识别、数据提取
|
Web App开发 大数据 应用服务中间件
什么是 HTTP Range请求(范围请求)
HTTP Range 请求是一种非常有用的 HTTP 功能,允许客户端请求资源的特定部分,从而提高传输效率和用户体验。通过合理使用 Range 请求,可以实现断点续传、视频流播放和按需加载等功能。了解并掌握 HTTP Range 请求的工作原理和应用场景,对开发高效的网络应用至关重要。
2140 16
|
负载均衡 Java Spring
Spring cloud gateway 如何在路由时进行负载均衡
Spring cloud gateway 如何在路由时进行负载均衡
2645 15
|
消息中间件 监控 Kafka
深入解析:Kafka 为何不支持全面读写分离?
**Kafka 2.4 引入了有限的读写分离,允许Follower处理只读请求,以缓解Leader压力。但这不适用于所有场景,特别是实时数据流和日志分析,因高一致性需求及PULL同步方式导致的复制延迟,可能影响数据实时性和一致性。在设计系统时需考虑具体业务需求。**
325 1
|
缓存 网络协议 Linux
性能工具之网络 Benchmark iperf3 快速入门
Benchmark 评估服务器之前的网络带宽简单方法,大家做性能测试是否也是这样评估网络带宽?
1038 2
性能工具之网络 Benchmark iperf3 快速入门
|
Kubernetes 网络协议 Cloud Native
Kubernetes网络问题排查分享两则(1)——calico特定场景下的网络性能问题
在对Kubernetes项目[kosmos](https://github.com/kosmos-io/kosmos)与Calico网络性能进行对比测试时,发现kosmos在跨集群容器网络的性能显著优于Calico的集群内网络(约6Gbit/s对比2.9Gbit/s)。物理机网络测试达到9.38Gbit/s,显示Calico有68%的性能损耗。问题定位到网卡的checksum/offload参数,尝试用`ethtool`调整后虽短暂提升,但随后恢复原状。转载自:https://mp.weixin.qq.com/s/XsQZCSqZAXJK46zqc7IpLw
|
SQL 关系型数据库 MySQL
orchestrator搭建mysql高可用
orchestrator搭建mysql高可用
556 0