CCDAK practice question 13 of 25

By default, which replica will be elected as a partition leader? (select two)

Full set: 150 questions
Answer options
A: Preferred leader broker if it is in-sync and auto.leader.rebalance.enable=true Correct answer
B: Any of the replicas
C: Preferred leader broker if it is in-sync and auto.leader.rebalance.enable=false
D: An in-sync replica Correct answer
Correct Answer:
A. Preferred leader broker if it is in-sync and auto.leader.rebalance.enable=true; D. An in-sync replica
Explanation

By default, Kafka has two primary scenarios for electing a partition leader. First, during a broker failure, the controller must elect a new leader. To prevent data loss, the default configuration (unclean.leader.election.enable=false) mandates that the new leader must be chosen from the set of followers that are fully caught up, known as the In-Sync Replicas (ISR). Second, Kafka uses a "preferred leader" concept for load balancing. By default, automatic leader rebalancing is enabled (auto.leader.rebalance.enable=true). This feature periodically checks if a partition's current leader is its preferred leader. If not, and the preferred leader is in the ISR, a leader election is triggered to move leadership back to that specific broker.

Why Incorrect

B. By default (unclean.leader.election.enable=false), only in-sync replicas are eligible for leadership to prevent data loss. Replicas that are not in-sync cannot be elected.
C. This is incorrect because it describes a non-default configuration. By default, auto.leader.rebalance.enable is set to true, not false.

References

1. Apache Kafka Documentation, Section 3.2 Replication: "The basic algorithm for leader election is simple: if a leader fails, a new leader is chosen from the set of in-sync replicas." This directly supports option D.

2. Confluent Documentation, Broker Configuration unclean.leader.election.enable: The default value is false, which "disables the ability to elect a leader from outside the ISR, ensuring no data loss." This directly refutes option B.

3. Confluent Documentation, Broker Configuration auto.leader.rebalance.enable: The default value is true. The documentation states this "Enables automatic leader balancing. A background thread checks and triggers leader elections to balance leadership in the cluster." This supports the scenario described in option A as a default behavior.

4. Designing Data-Intensive Applications by Martin Kleppmann, Chapter 5: Replication, "Leader-Based Replication" section: This academic resource explains that in leader-based replication systems like Kafka, a new leader must be chosen from an up-to-date replica (an in-sync replica) to maintain consistency guarantees. This reinforces the principle behind option D.

Scroll to Top