负载均衡器在 RabbitMQ 中的工作原理 [英] How load balancer works in RabbitMQ

查看:27
本文介绍了负载均衡器在 RabbitMQ 中的工作原理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 RabbitMQ 的新手,所以请原谅我的琐碎问题:

I am new to RabbitMQ, so please excuse me for trivial questions:

1) 在 RabbitMQ 集群的情况下,如果一个节点发生故障,负载转移到另一个节点(不停止其他节点).同样,我们也可以在不停止集群中现有节点的情况下向现有集群添加新节点.对吗?

1) In case of clustering in RabbitMQ, if a node fails, load shift to another node (without stopping the other nodes). Similarly, we can also add new fresh nodes to the existing cluster without stopping existing nodes in cluster. Is that correct?

2) 假设我们从单个 rabbitMQ 节点开始,并在其上创建 100 个队列.现在生产者开始以更快的速度发送消息.为了处理这种负载,我们添加了更多节点并创建了一个集群.但是队列只存在于第一个节点上.现在节点之间的负载均衡如何?如果我们需要添加更多队列,我们​​应该在哪个节点上添加它们?或者我们可以使用负载均衡器添加它们.

2) Assume that we start with a single rabbitMQ node, and create 100 queues on it. Now producers started sending message at faster rate. To handle this load, we add more nodes and make a cluster. But queues exist on first node only. How does load balanced among nodes now? And if we need to add more queues, on which node we should add them? Or can we add them using load balancer.

提前致谢

推荐答案

1) 在 RabbitMQ 集群的情况下,如果一个节点发生故障,负载转移到另一个节点(不停止其他节点).同样,我们也可以在不停止集群中现有节点的情况下向现有集群添加新节点.对吗?

1) In case of clustering in RabbitMQ, if a node fails, load shift to another node (without stopping the other nodes). Similarly, we can also add new fresh nodes to the existing cluster without stopping existing nodes in cluster. Is that correct?

如果创建队列的节点出现故障,只要启用了队列的镜像,rabbitmq 就会在集群中为该队列选择一个新的主节点.集群根据您可以定义的策略提供 HA.

If a node on which the queue was created fails, rabbitmq will elect a new master for that queue in the cluster as long as mirroring for the queue is enabled. Clustering provides HA based on a policy that you can define.

2) 假设我们从单个 rabbitMQ 节点开始,并在其上创建 100 个队列.现在生产者开始以更快的速度发送消息.为了处理这种负载,我们添加了更多节点并创建了一个集群.但是队列只存在于第一个节点上.现在节点之间的负载均衡如何?

2) Assume that we start with a single rabbitMQ node, and create 100 queues on it. Now producers started sending message at faster rate. To handle this load, we add more nodes and make a cluster. But queues exist on first node only. How does load balanced among nodes now?

负载不平衡.分布式集群提供 HA 而不是负载平衡.您的请求将被重定向到队列所在的集群中的节点.

The load is not balanced. The distributed cluster provides HA and not load balancing. Your requests will be redirected to the node in the cluster on which the queue resides.

如果我们需要添加更多队列,我们​​应该在哪个节点上添加它们?或者我们可以使用负载均衡器添加它们.

And if we need to add more queues, on which node we should add them? Or can we add them using load balancer.

这取决于您的用例.有些人使用循环并在不同的节点上创建队列.

That depends on your use case. Some folks use a round robin and create queues on separate nodes.

  • 对于 HA,请在集群中使用 镜像.
  • 要跨节点平衡负载,请使用 LB 来跨队列分发.
  • 如果您想对队列本身进行负载平衡,请查看联合队列.它们允许您从上游队列中获取下游队列上的消息.
  • For HA use mirroring in the cluster.
  • To balance load across nodes, use a LB to distribute across Queues.
  • If you'd like to load balance the queue itself take a look at Federated Queues. They allow you to fetch messages on a downstream queue from an upstream queue.

这篇关于负载均衡器在 RabbitMQ 中的工作原理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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