When does the election of Kafka's leader take place?

When and how often does a high-level Kafky producer choose a leader? Does it do before sending each message, or only once during the creation of the connection?

+4
source share
1 answer

Each broker has information about the list of topics (and sections) and their leaders, which will be updated by the zoo keeper whenever a new leader is elected or when the number of sections changes.

Thus, when a manufacturer makes a call to one of the brokers, he answers with this information list. As soon as the manufacturer receives this information, he caches it and uses it to connect with the leader. Therefore, the next time he wants to send a message on this topic (and section), he will use this cached information.

Suppose there was only one leader, and there were no replicas for this section / section, and it was crushed. In this case, he will try to connect to this leader, and he fails. He will try to get a leader from another list of brokers that he cached to check if there is any leader for this topic! Since he will not find him, he will try to hit the same leader (who is dead), and after reaching the maximum number of attempts, he will throw an exception !!

+3

Source: https://habr.com/ru/post/1673734/


All Articles