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

查看:456
本文介绍了负载均衡器在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天全站免登陆