Explain the role of the Controller in a Kafka cluster.
Instruction: Describe the responsibilities and significance of the Controller in Apache Kafka's architecture.
Updated
Official answer
In Kafka 4.x, controllers are members of the KRaft metadata quorum. One is active as its leader; other voters replicate metadata and can participate in electing a replacement. A controller is not necessarily a broker: process roles may be separate or combined.
The active controller manages metadata such as broker registration/liveness, topic and partition changes, partition leadership and replica reassignment. Brokers serve the partition data path and follow the metadata decisions. The metadata quorum and each partition's data-replication state are different systems of responsibility.
If a broker fails, the controller can arrange leadership changes according to eligible replica rules. Recovery may be unavailable if there is no safe leader or no communicating metadata majority. Controller election is not a guarantee that every client operation is interruption-free.
Monitor quorum leader/follower progress, election behavior, broker registration and partition health. Under-replicated partitions indicate replicas falling short of the expected synchronized state; they do not necessarily mean the configured replication factor or assigned replica count changed.
Use supported reassignment and controller membership/recovery procedures. Adding a broker does not automatically move all historical replicas, and a controller does not make cross-cluster disaster recovery synchronous. Verify actual placement, catch-up and application recovery after changes.
KRaft architecture and operations, partition reassignment, monitoring