Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing
Back
  1. Home
  2. Interview prep
  3. What is the Kafka Controller?

Kafka · Core Concepts

What is the Kafka Controller?

Mediumkafka-07
controllerleader electionmetadatafailover

Question

What does the Kafka Controller do?

Solution

The Controller is a special broker role that manages cluster-wide metadata and leadership.

Main jobs

  • Track which brokers are alive
  • Assign partition leaders and replicas
  • React when a broker joins or leaves
  • Trigger leader elections when a leader broker fails
  • Update metadata so clients learn new leaders
Broker failure detected
        ↓
   Controller
        ↓
 Elect new leader from ISR for affected partitions
        ↓
 Propagate metadata update to brokers / clients

ZooKeeper vs KRaft controllers

  • ZooKeeper mode: one broker is elected controller (via ZooKeeper); failover elects another.
  • KRaft mode: a quorum of controllers (Raft) maintains metadata; one is the active leader controller.

Why interviews ask this

If partition leaders never moved after a crash, those partitions would stay unavailable. The controller is the brain that keeps the cluster consistent when membership changes.

Not the same as partition leader

  • Controller: cluster metadata / who leads which partition.
  • Partition leader: the replica that accepts writes/reads for one partition.

Interview tip: "Controller manages the cluster; partition leader manages one partition's log."

PreviousNext