In-sync Replicas (ISR) in Kafka
📖 Scenario: You are managing a Kafka cluster that replicates messages across multiple brokers to keep data safe. You want to understand which replicas are currently in-sync with the leader to ensure data reliability.
🎯 Goal: Build a simple Kafka script that lists the in-sync replicas (ISR) for a given topic partition.
📋 What You'll Learn
Create a dictionary called
topic_partitions with one entry: key 'my_topic-0' and value {'replicas': [1, 2, 3], 'leader': 1, 'isr': [1, 2]}Create a variable called
partition_key and set it to 'my_topic-0'Use a
for loop with variable replica to iterate over the replicas and check if each is in the ISR listCreate a list called
replica_status that stores strings like 'Replica 1 is in-sync' or 'Replica 3 is out-of-sync'Print each string in
replica_status on a new line💡 Why This Matters
🌍 Real World
Kafka uses in-sync replicas to ensure data is safely replicated across brokers. Monitoring ISR helps maintain data durability and availability.
💼 Career
Understanding ISR is important for roles like Kafka administrators, DevOps engineers, and backend developers working with distributed systems.
Progress0 / 4 steps