0
0
Kafkadevops~10 mins

Controller broker in Kafka - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Controller broker
Start Kafka Cluster
Elect Controller Broker
Controller Broker Manages Cluster
Monitor Broker States
Handle Partition Leadership Changes
Update Metadata for Brokers
Detect Broker Failures
Trigger Reassignments
Continue Managing Until Controller Changes
The controller broker is elected when the Kafka cluster starts and manages cluster metadata, broker states, and partition leadership until a new controller is elected.
Execution Sample
Kafka
1. Start Kafka cluster
2. Elect controller broker
3. Controller monitors brokers
4. Handle leader changes
5. Update metadata
6. Detect failures and reassign
This sequence shows how the controller broker manages cluster state and broker leadership dynamically.
Process Table
StepActionController StateCluster MetadataOutput
1Start Kafka clusterNo controllerEmptyCluster starts
2Elect controller brokerController elected (Broker 1)EmptyController ready
3Controller monitors brokersActiveMetadata updated with brokersMonitoring brokers
4Handle leader changesActivePartition leaders updatedLeaders assigned
5Update metadataActiveMetadata refreshedMetadata broadcasted
6Detect broker failureActiveMetadata marks broker downTrigger reassignment
7Trigger reassignmentActivePartition leadership reassignedCluster stable
8Controller continues managingActiveMetadata currentWaiting for events
9Controller failureController lostMetadata frozenNew controller election triggered
10New controller electedController elected (Broker 2)Metadata refreshedCluster managed again
💡 Controller failure triggers new election, restarting management cycle
Status Tracker
VariableStartAfter Step 2After Step 5After Step 7After Step 9After Step 10
Controller StateNo controllerController elected (Broker 1)ActiveActiveController lostController elected (Broker 2)
Cluster MetadataEmptyEmptyMetadata refreshedPartition leadership reassignedMetadata frozenMetadata refreshed
Broker StatusUnknownKnownKnownBroker 3 downBroker 3 downKnown
Key Moments - 3 Insights
Why does the controller broker change during cluster operation?
When the current controller fails or loses connection (see step 9 in execution_table), a new controller is elected to maintain cluster management.
How does the controller broker handle broker failures?
It detects failures (step 6), updates metadata to mark brokers down, and triggers partition leadership reassignment (step 7) to keep the cluster stable.
What happens to cluster metadata when the controller changes?
Metadata is frozen during controller loss (step 9) and refreshed by the new controller after election (step 10) to ensure accurate cluster state.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the controller state after step 5?
ANo controller
BController elected (Broker 1)
CActive
DController lost
💡 Hint
Check the 'Controller State' column at step 5 in execution_table
At which step does the controller detect a broker failure?
AStep 4
BStep 6
CStep 8
DStep 10
💡 Hint
Look for 'Detect broker failure' action in execution_table
If the controller never fails, which step would NOT occur?
AStep 9: Controller failure
BStep 7: Trigger reassignment
CStep 4: Handle leader changes
DStep 5: Update metadata
💡 Hint
Refer to execution_table steps related to controller failure and election
Concept Snapshot
Controller broker manages Kafka cluster metadata and broker states.
It is elected at cluster start and handles leader changes and failures.
Detects broker failures and triggers partition reassignment.
If controller fails, a new one is elected to continue management.
Ensures cluster stability and metadata consistency.
Full Transcript
The controller broker in Kafka is elected when the cluster starts. It manages cluster metadata, monitors broker states, handles partition leadership changes, updates metadata, detects broker failures, and triggers reassignment of partitions. If the controller fails, a new controller is elected to maintain cluster stability. This process ensures the Kafka cluster runs smoothly by coordinating brokers and partition leadership dynamically.