Kafka Leader选举什么时候举行? [英] When does Kafka Leader Election happen?

查看:36
本文介绍了Kafka Leader选举什么时候举行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Kafka High Level Producer 何时以及多久选举一次领导人?是在发送每条消息之前执行还是仅在创建连接时执行一次?

When and how often does Kafka High Level Producer elect a leader? Does it do before sending each message or only once at the time of creating connection?

推荐答案

每个 Broker 都有一个关于主题列表(和分区)及其领导者的信息,每当新领导者出现时,动物园管理员都会更新这些信息选择或分区数量发生变化时.

Every broker has a information about the list of topics(and partitions) and their leaders which will be kept up to date by the zoo keeper whenever the new leader is elected or when the number of partition changes.

因此,当生产者调用其中一个代理时,它会使用此信息列表进行响应.一旦生产者收到此信息,它就会缓存它并使用它来连接到领导者.因此,下次当它想要将消息发送到特定主题(和分区)时,它将使用此缓存信息.

Thus, when the producer makes a call to one of the brokers, it responds with this information list. Once the producer receives this information, it caches this and uses it to connect to the leader. So next time when it wants to send the message to that particular topic (and partition) it will use this cached information.

让我们假设只有一个领导者,并且该主题/分区二人组没有副本,并且它被粉碎了.在这种情况下,它将尝试连接到该领导者,但失败了.它将尝试从它缓存的其他代理列表中获取领导者,以检查该主题是否有任何领导者!由于它没有找到任何,它会尝试命中同一个领导者(即死亡),并在达到最大重试次数后抛出异常!!

Lets assume there was only one leader and there are no replicas for that topic/ partition duo and it got crushed. In this case it will try to connect to that leader and it fails. It will try to fetch the leader from the other brokers list which it has cached to check if there is any leader for this topic! As it does not find any, it will try to hit to the same leader(that is dead) and after reaching a maximum no of retries it will throw an exception !!

这篇关于Kafka Leader选举什么时候举行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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