Bird
0
0

You have this Kafka consumer code snippet:

medium📝 Debug Q14 of 15
Kafka - Event-Driven Architecture
You have this Kafka consumer code snippet:
consumer.subscribe(['topic1'])
for message in consumer:
    print(message.value)
    consumer.commit()

What is the main issue that can cause scaling problems?
APrinting message values is not allowed in Kafka consumers.
BCalling commit() inside the loop slows processing and blocks scaling.
CNot subscribing to the topic correctly.
DUsing a for loop instead of while True.
Step-by-Step Solution
Solution:
  1. Step 1: Identify commit() impact on performance

    Calling commit() after every message waits for confirmation, slowing down processing.
  2. Step 2: Understand scaling impact

    This slows consumer throughput and limits how well the app can scale with many messages.
  3. Final Answer:

    Calling commit() inside the loop slows processing and blocks scaling. -> Option B
  4. Quick Check:

    Frequent commit() = Slow processing = Poor scaling [OK]
Quick Trick: Avoid commit() inside message loop for better scaling [OK]
Common Mistakes:
  • Thinking subscribe() is incorrect syntax
  • Believing print() causes errors
  • Confusing loop type with scaling issue

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes