卡夫卡领导人选举何时举行? [英] When does Kafka Leader Election happen?

查看:89
本文介绍了卡夫卡领导人选举何时举行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

卡夫卡高级制作人何时,多久选举一位领导者? 它是在发送每条消息之前执行还是在建立连接时仅执行一次?

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?

推荐答案

每个经纪人都拥有有关主题(和分区)及其首领列表的信息,只要新的首领被任命,动物园饲养员就会将其保持最新.当选或者当分区改变的次数.

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 !!

这篇关于卡夫卡领导人选举何时举行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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