Learn Labs
4. Kafka Consumers: Reading Data from Kafka

4.15 Self-test

Self-test33 questions

—/33
  1. Why does adding a 5th consumer to a 4-partition topic do nothing? What's the general rule?

  2. When do you create a new consumer group vs add a consumer to an existing one?

  3. List the three events that trigger a rebalance.

  4. Contrast eager and cooperative rebalance phase-by-phase. Which partitions keep flowing in each?

  5. There are two independent mechanisms for detecting a dead consumer. Name both, and explain the specific failure each one catches that the other cannot.

  6. Why does a clean close() reduce downtime compared to a crash?

  7. Who computes partition assignments — a broker or a client? What does each consumer get to see?

  8. What does group.instance.id change, and what new risk does it introduce?

  9. Why is tuning session.timeout.ms harder under static membership?

  10. Why is the poll() line called "the most important line in the chapter"?

  11. Name three things poll() does besides fetching records. Why does that make it the source of most consumer exceptions?

  12. Producers are thread-safe; consumers are not. What are the two supported concurrency patterns?

  13. What changed between poll(long) and poll(Duration), and what's the standard replacement for the poll(0) hack?

  14. Explain fetch.min.bytes + fetch.max.wait.ms as a pair. What does each protect?

  15. Why does the book prefer fetch.max.bytes over max.partition.fetch.bytes?

  16. What's the relationship between max.poll.records and max.poll.interval.ms?

  17. Why is lowering request.timeout.ms counterproductive during an incident?

  18. Give the three auto.offset.reset values and the specific risk of each.

  19. Draw the two offset failure modes (committed < processed, committed > processed) and name the consequence of each.

  20. Precisely which offset gets committed by default, and what's the manual-commit rule?

  21. Autocommit + an exception mid-batch + continue = what bug? Trace it.

  22. Why does commitAsync() deliberately not retry? Give the 2000/3000 trace.

  23. Describe the sequence-number pattern for safe async commit retries.

  24. Why is commitAsync() in the loop plus commitSync() on shutdown the standard shape?

  25. You need to commit mid-batch. Why can't you just call commitSync()?

  26. Which rebalance-listener method commits offsets, and why must it be sync?

  27. What's the ordering guarantee across onPartitionsRevoked() and onPartitionsAssigned(), and why does it matter?

  28. When is onPartitionsLost() called, what's the hazard, and what happens if you don't implement it?

  29. What's the only consumer method safe to call from another thread? What exception does it produce, and where?

  30. Two ways regex subscription can bite you on a large cluster.

  31. offsets.retention.minutes is a broker config. Describe the consumer-visible failure it causes.

  32. subscribe() vs assign(): list what you gain and what you give up. What silently stops working with assign()?

  33. Your output database was wiped. How do you rebuild it from Kafka, and what bounds whether you can?

    Previous: Chapter 3 — Kafka Producers Next: Chapter 5 — Managing Kafka Programmatically