【原创】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 信息;




相关实践学习
5分钟轻松打造应对流量洪峰的稳定商城交易系统
本实验通过SAE极速部署一个微服务电商商城,同时结合RocketMQ异步解耦、削峰填谷的能力,带大家体验面对流量洪峰仍旧稳定可靠的商城交易系统!
消息队列 MNS 入门课程
1、消息队列MNS简介 本节课介绍消息队列的MNS的基础概念 2、消息队列MNS特性 本节课介绍消息队列的MNS的主要特性 3、MNS的最佳实践及场景应用 本节课介绍消息队列的MNS的最佳实践及场景应用案例 4、手把手系列:消息队列MNS实操讲 本节课介绍消息队列的MNS的实际操作演示 5、动手实验:基于MNS,0基础轻松构建 Web Client 本节课带您一起基于MNS,0基础轻松构建 Web Client
目录
打赏
0
0
0
0
34
分享
相关文章
10个问题带你了解 Compose Multiplatform 1.0
10个问题带你了解 Compose Multiplatform 1.0
577 0
GitHub:如何从GitHub上下载文件(下载单个文件或者下载整个项目文件)之详细攻略(图文教程)
GitHub:如何从GitHub上下载文件(下载单个文件或者下载整个项目文件)之详细攻略(图文教程)
GitHub:如何从GitHub上下载文件(下载单个文件或者下载整个项目文件)之详细攻略(图文教程)
Spring cloud gateway 如何在路由时进行负载均衡
Spring cloud gateway 如何在路由时进行负载均衡
1301 15
长桥科技:通过Terraform自动化为客户提供安全、高效的产品服务体验
长桥科技通过采用Terraform加速业务上线,实现云资源的高效管理。作为一家金融科技公司,长桥为证券、资管等机构提供数字化解决方案。其SRE团队利用Terraform构建CICD流程,自动化配置云资源及应用配置,简化了基础设施管理,提升了开发效率。通过模块化和自动化部署,新租户的配置从一天缩短至20分钟,显著减少了人力成本和操作复杂度。此外,长桥还遵循编程规范,确保代码的可测试性和复用性,进一步优化了云上基础设施的构建与管理。
【大数据】数据治理浅析
数据治理是数字化时代企业管理和利用数据的核心手段,确保数据的准确性、一致性和安全性。从基本概念、应用场景、必要性、需求分析等方面深入探讨其功能架构、技术架构、应用架构和数据架构,涵盖金融、医疗、应急管理等多个领域典型案例。随着政策法规推动、技术创新助力及市场需求增长,数据治理正朝着自动化、智能化方向发展,市场规模不断扩大,但人才短缺问题仍需解决。
414 11
【大数据】数据治理浅析
阿里云《AI 剧本生成与动画创作》解决方案技术评测
随着人工智能技术的发展,越来越多的工具和服务被应用于内容创作领域。阿里云推出的《AI 剧本生成与动画创作》解决方案,利用函数计算 FC 构建 Web 服务,结合百炼模型服务和 ComfyUI 工具,实现了从故事剧本撰写、插图设计、声音合成和字幕添加到视频合成的一站式自动化流程。本文将对该方案进行全面的技术评测,包括实现原理及架构介绍、部署文档指引、具体耗时分析以及实际使用体验。
387 16
零门槛体验DeepSeek-R1满血版评测
本文评测了“零门槛、轻松部署您的专属DeepSeek模型”解决方案。文档步骤清晰,逻辑顺畅,特别在调用API和配置客户端方面指引详细,确保部署顺利。体验过程中提供了充足引导与帮助,涵盖多种部署方式如百炼API调用、PAI平台部署等,适合不同需求用户。推荐基于百炼API的满血版,因其快速上手、按量付费、弹性扩展和易于管理的优势。整体方案基本满足实际需求,建议进一步补充性能评估和成本优化等内容。
257 18
Linux使用cpulimit对CPU使用率进行限制
cpulimit是一款简单易用的CPU使用率限制工具,支持对特定程序或整个CPU使用率进行限制。可通过源安装(如`yum`或`apt-get`)或编译安装获取。使用时,可针对程序名、进程号或绝对路径设置CPU占用上限(如`cpulimit -e xmrig -l 60 -b`)。ROOT用户可限制所有进程,普通用户仅限于权限范围内进程。注意,CPU百分比基于实际核心数(单核100%,双核200%,依此类推)。
218 7

热门文章

最新文章

AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等

登录插画

登录以查看您的控制台资源

管理云资源
状态一览
快捷访问