GAP·MAP
← all breakdowns
KafkaPartitionsConsumer GroupsOffsetsmiddle level

Kafka Partitions and Consumer Groups

the question

A Kafka topic has six partitions. What happens as consumers join the same consumer group, and what changes if they use different group IDs? Explain the effects on ordering, offsets, and rebalancing.

what they're testing: The interviewer is probing whether you can reason about Kafka's scaling boundary, ordering guarantee, and recovery behavior as consumer membership changes.

a strong answer

Partitions are the unit Kafka uses for ordering and consumer parallelism. Kafka preserves record order within each partition, not across a whole topic. With the default producer partitioning logic, records that have the same key go to the same partition, so related events can stay ordered.

Consumers sharing a group.id act as one logical subscriber. Kafka assigns each partition to exactly one member of that group at a time, although one consumer may own several partitions. With six partitions, at most six consumers in the group can receive assignments; a seventh or eighth consumer is idle. A different group gets its own assignments and committed offsets, so two groups can read the same retained records independently.

When a subscribed consumer joins, leaves, or is considered failed, Kafka reassigns partitions within the group. A new owner normally starts from the group's committed offset. If no valid committed offset exists, auto.offset.reset controls where it starts. Processing records and then crashing before the offset commit can cause duplicate processing. Committing first can cause records to go unprocessed after a crash. More partitions raise the group's parallelism ceiling, while the partitioning strategy still determines ordering boundaries and potential hot spots.

Where people slip

the tempting wrong answer, and what's actually true

  • Every consumer in the same group receives a copy of every record.

    Within a consumer group, each partition is assigned to one member at a time, so records from that partition go to that assigned member.

  • Adding consumers always increases throughput, even when there are more consumers than partitions.

    A group cannot have more actively assigned consumers than its subscribed partitions, so extra consumers receive no partition assignment.

  • Kafka guarantees record order across every partition in a topic.

    Kafka guarantees order within a topic-partition, not across the topic as a whole.

  • Kafka deletes a record as soon as a consumer reads it.

    Reading a record does not delete it. A consumer's current position advances as it polls, committed offsets track group progress for recovery, and the topic's cleanup policy controls when records are removed.

If they push further

What triggers a consumer group rebalance, and why can it hurt?

Membership changes and changes to subscribed topic partitions can trigger reassignment. Moving ownership interrupts or delays work and can expose poor offset handling, so stable membership and the rebalance protocol matter operationally.

How does offset commit timing change delivery semantics?

Processing successfully before committing can provide at-least-once behavior and may repeat work after a crash. Committing first provides at-most-once behavior and can skip processing, while exactly-once results require atomic coordination between output and offsets.

How would you choose a partition key and partition count?

Choose a key that keeps events requiring order together while distributing load evenly. Size the partition count for expected throughput and consumer parallelism, then account for skew and the operational cost of additional partitions.

Sources

Now answer it yourself.

Reading a strong answer is easy. Producing one under pressure is the skill the interview tests. Gapmap grades your answer against the same bar an interviewer would.

was this useful?

beta

The interviewer part is in the works.

The diagnostic, personal maps, and AI mock interviews are being finished right now. The notes stay free either way. Leave an email and you'll get the first-cohort invite, plus a month of Pro when it opens.