Unit 4 of 15 · about 4 hours · explain

Pull consumers, fetch positions, consumer groups and rebalance protocols

The consumer group is where ordering meets parallelism: each partition gets exactly one reader, and every membership change moves that reader. Rebalance behavior decides what pauses and what repeats.

You'll be able to

  • Explain pull with fetch positions and why the broker keeps no per-message acknowledgement state.
  • Explain consumer groups, partition ownership and static membership with group.instance.id.
  • Explain rebalance generations and what pauses or duplicates a rebalance can cause.

Covers

Consumers, pull loops and fetch positionsConsumer groups and ownershipAssignment and rebalance protocols
1

Read

In this order, only the parts listed

0 of 3 done

  1. Consumer groups and coarse-grained load balancingDDIA 2e - Chapters 11 to 13 Batch and Stream Processing

    Chapter 12, Multiple consumers with Figure 12-1 (pp. 492 to 493): load balancing versus fan-out, consumer groups; Log-Based Message Brokers (p. 497): shard assignment to group members, single-threaded shard consumption, head-of-line blocking

  2. The consumer: pull, position and static membershipApache Kafka 4.3 - Design, Log, Rebalance and Transaction Protocols

    The Consumer (pull and long-poll rationale); Consumer Position (position as one integer offset with rewind support); Static Membership (group.instance.id with fenced restarts)

  3. Consumer rebalance protocolApache Kafka 4.3 - Design, Log, Rebalance and Transaction Protocols

    Overview (KIP-848, generally available since 4.0: Consumer versus Classic groups, server-side assignors); Consumer (opt-in with group.protocol=consumer); Upgrade and Downgrade

    Read the Overview and Consumer sections only. In 4.3 the Consumer protocol is opt-in; the 5.0 default change is out of scope.

2

Focus on

  • Consumers pull and track one integer position per partition. The broker never tracks which message each consumer saw, which is why offsets are cheap.
  • A group assigns each partition to exactly one member; two groups over one topic give fan-out across groups. Members beyond the partition count sit idle.
  • Rebalance moves ownership on join, leave or crash, fenced by generations, with static members keeping partitions across rolling restarts. During the pause nobody reads the moved partitions.
  • A member that processed records but did not commit before losing its partitions causes those records to be redelivered to the new owner.
Common mistakes · 3
  • Adding more consumers than partitions to raise throughput. Extra members sit idle; raise partitions instead.
  • Expecting KIP-848 behavior from default clients. In 4.3 the Consumer protocol needs group.protocol=consumer.
  • Treating a rebalance as lossless by itself. Ownership moves; which records repeat depends on committed offsets, not on the protocol.
3

Try it yourself

Closed-book, before checking anything

Closed-book, trace a 6-partition topic across a 3-member group when one member dies: which partitions move, what the new owners fetch first, and which records repeat.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.Six partitions, four live members, then a fifth member joins. How many members read, and with what split?Answer

    All five read, split 2, 1, 1, 1 and 1, since each partition has exactly one owner. A member sits idle only when members outnumber partitions.

  2. 2.A member has committed position 10 (offsets up to 9 done), processes offsets 10 to 12, then crashes before its next commit, and its partitions move. Where does the new owner start, and what repeats?Answer

    It resumes at 10, the committed position. Offsets 10 to 12 are delivered and processed a second time.

  3. 3.What does group.instance.id change on a rolling restart?Answer

    The restarted process rejoins as the same static member, so if it returns within the session timeout it keeps its partitions and no rebalance moves ownership. Records it processed but had not committed before the restart are still read again.

  4. 4.Why do log-based brokers pull instead of pushing?Answer

    Pull lets each consumer control its rate, batching and replay position, and keeps the broker free of per-consumer acknowledgement state.

You're done when

You can assign partitions to any group size, predict the redelivery after a member death, and state when no rebalance happens at all.

Only when you can do this without notes.

Leads to

Notes

Resources · 2 for this unit, 16 more in the section
  • DDIA 2e - Chapters 11 to 13 Batch and Stream ProcessingMartin Kleppmann and Chris Riccomini · primary

    Read batch processing, stream processing and the streaming-systems philosophy in order. For every guarantee, mark the source position, operator state, output effect and recovery boundary it actually covers.

  • Apache Kafka 4.3 - Design, Log, Rebalance and Transaction ProtocolsApache Kafka · required

    Read the 4.3 design page (replication and in-sync replicas, acknowledgements and min.insync.replicas, delivery semantics, idempotence and transactions, the consumer, log compaction), the log implementation page, and the consumer rebalance protocol and transaction protocol pages (https://kafka.apache.org/43/operations/). Kafka 4.0 removed ZooKeeper. Run experiments in the apache/kafka:4.3.1 image and compare each contract with your mini log.

Also in this section