📖 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
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
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
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
Hint
Use a simple for loop to print each message.
Practice
(1/5)
1. Which statement best describes an active-passive Kafka cluster setup?
easy
A. One cluster is active handling all traffic, the other is standby for failover.
B. Both clusters actively handle traffic and share the load equally.
C. Clusters are inactive until manually started.
D. Clusters are used only for backup storage without processing.
Solution
Step 1: Understand active-passive setup
Active-passive means one system is active and the other waits as backup. One cluster is active handling all traffic, the other is standby for failover. matches this exactly: one active, one standby for failover.
Final Answer:
One cluster is active handling all traffic, the other is standby for failover. -> Option A
Quick Check:
Active-passive = one active, one standby [OK]
Hint: Active-passive means only one active system at a time [OK]
Common Mistakes:
Confusing active-active with active-passive
Thinking both clusters handle traffic simultaneously
Assuming passive cluster processes data
2. Which Kafka cluster configuration syntax correctly represents an active-active setup?
easy
A. A single cluster with no replication.
B. Two clusters with separate Zookeeper ensembles, both processing data simultaneously.
C. One cluster with a passive standby cluster defined but not processing data.
D. Two clusters where one is always offline.
Solution
Step 1: Identify active-active setup syntax
Active-active means multiple clusters actively processing data at the same time. Two clusters with separate Zookeeper ensembles, both processing data simultaneously. describes two clusters with separate Zookeeper ensembles both active simultaneously.
Final Answer:
Two clusters with separate Zookeeper ensembles, both processing data simultaneously. -> Option B
Quick Check:
Active-active = multiple active clusters [OK]
Hint: Active-active means multiple active clusters running simultaneously [OK]
Common Mistakes:
Choosing passive cluster syntax for active-active
Ignoring Zookeeper ensemble separation
Assuming single cluster can be active-active
3. Given two Kafka clusters configured in active-active mode, what is the expected behavior when a message is produced to both clusters simultaneously?
medium
A. Messages are processed independently and replicated asynchronously between clusters.
B. Only one cluster accepts messages; the other rejects them.
C. Messages are lost if produced to both clusters at the same time.
D. Clusters merge messages automatically without conflicts.
Solution
Step 1: Understand active-active message handling
In active-active, both clusters accept messages and replicate asynchronously. Messages are processed independently and replicated asynchronously between clusters. correctly states messages are processed independently and replicated asynchronously between clusters.
Final Answer:
Messages are processed independently and replicated asynchronously between clusters. -> Option A
Thinking messages get lost on simultaneous produce
Believing clusters merge messages automatically
4. You configured a Kafka cluster in active-passive mode but both clusters are processing messages simultaneously. What is the likely cause?
medium
A. Kafka does not support active-passive mode.
B. Passive cluster is offline.
C. Zookeeper ensemble is shared correctly.
D. Failover mechanism is not properly configured, causing both to be active.
Solution
Step 1: Identify expected active-passive behavior
Only one cluster should be active; the other should be standby. If both are active, failover or coordination is misconfigured, allowing both to process.
Final Answer:
Failover mechanism is not properly configured, causing both to be active. -> Option D
Quick Check:
Misconfigured failover = both active [OK]
Hint: Check failover setup if both active in active-passive mode [OK]
Common Mistakes:
Assuming Kafka can't do active-passive
Ignoring failover configuration
Thinking shared Zookeeper means passive is active
5. You want to design a Kafka deployment for a critical application requiring zero downtime and high throughput. Which setup is best and why?
hard
A. Single cluster with no replication, to reduce complexity.
B. Active-passive, because one cluster handles all traffic and the other is backup.
C. Active-active, because multiple clusters share load and provide failover simultaneously.
D. Passive-only clusters to save resources.
Solution
Step 1: Identify requirements
Zero downtime and high throughput require load sharing and failover. Active-active allows multiple clusters to share load and provide failover simultaneously.
Final Answer:
Active-active, because multiple clusters share load and provide failover simultaneously. -> Option C
Quick Check:
High availability + throughput = active-active [OK]
Hint: Active-active suits zero downtime and high throughput needs [OK]
Common Mistakes:
Choosing active-passive for high throughput
Ignoring failover and load sharing benefits
Selecting single cluster risking downtime
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.