0
0
Kafkadevops~30 mins

Active-passive vs active-active in Kafka - Hands-On Comparison

Choose your learning style9 modes available
Active-passive vs active-active Kafka Setup
📖 Scenario: You are managing a Kafka messaging system for a small company. You want to understand the difference between active-passive and active-active setups by simulating message sending and receiving in both modes.
🎯 Goal: Build a simple Python simulation that shows how messages are handled differently in active-passive and active-active Kafka cluster setups.
📋 What You'll Learn
Create a dictionary called kafka_clusters with two keys: 'active_passive' and 'active_active', each holding a list of broker names.
Create a variable called message with the exact string 'Hello Kafka!'.
Write a loop that simulates sending the message to all brokers in the active_active cluster.
Print the messages sent to each broker in the active_active cluster.
💡 Why This Matters
🌍 Real World
Kafka clusters are used in real companies to handle data streams reliably. Understanding active-passive and active-active setups helps keep data flowing without interruption.
💼 Career
Knowing how to simulate and understand Kafka cluster modes is useful for roles in system administration, DevOps, and backend development where message reliability is critical.
Progress0 / 4 steps
1
Create Kafka cluster data
Create a dictionary called kafka_clusters with these exact entries: 'active_passive': ['broker1', 'broker2'] and 'active_active': ['brokerA', 'brokerB'].
Kafka
Need a hint?

Use a dictionary with two keys and lists of strings as values.

2
Set the message variable
Create a variable called message and set it to the string 'Hello Kafka!'.
Kafka
Need a hint?

Use a simple string assignment.

3
Simulate sending messages to active-active brokers
Write a for loop using broker as the variable to iterate over kafka_clusters['active_active'] and create a list called sent_messages that stores strings in the format f"Sent '{message}' to {broker}".
Kafka
Need a hint?

Use a list comprehension with the specified format.

4
Print the sent messages
Write a for loop using msg as the variable to iterate over sent_messages and print each msg.
Kafka
Need a hint?

Use a simple for loop to print each message.