Controller Broker Status Checker with Kafka
📖 Scenario: You are working with Apache Kafka, a system that helps send messages between different parts of a program. One important part is the controller broker, which manages how messages flow and keeps everything running smoothly.In this project, you will write a simple Python program to check which broker is the controller in a Kafka cluster. This helps you understand how Kafka manages its controllers.
🎯 Goal: Build a Python program that connects to a Kafka cluster, finds the controller broker ID, and prints it out.
📋 What You'll Learn
Create a dictionary called
brokers with broker IDs as keys and their hostnames as values: 1: 'broker1.example.com', 2: 'broker2.example.com', 3: 'broker3.example.com'Create a variable called
controller_id and set it to 2Use a
for loop with variables broker_id and host to iterate over brokers.items() and find the controller brokerPrint the message
"Controller broker is ID {controller_id} at {host}" using an f-string💡 Why This Matters
🌍 Real World
In real Kafka clusters, knowing which broker is the controller helps in monitoring and troubleshooting message flow and cluster health.
💼 Career
Understanding controller brokers is useful for roles like DevOps engineers, system administrators, and backend developers working with distributed systems and message queues.
Progress0 / 4 steps