Partitions, offsets and consumer groups
A stream topic, as in Apache Kafka, is split into partitions, each an independent ordered log. Every record in a partition has an offset, its position in that log, and a consumer group stores one offset per partition: a bookmark for where it has read up to. Think of partitions as lanes, offsets as positions along a lane, and a consumer group as a team of workers sharing the lanes.
Key to partition
The producer chooses the partition, usually by hashing the record’s key. Orders uses the order id as the key, so every event for order 1042 lands in the same partition, and Kafka guarantees that a consumer reads one partition’s records in the order they were written. That gives order per key and none across partitions.
A partition is not one order. It holds many keys, as the diagram shows, and many orders share each lane. Adding partitions to an existing topic does not move existing records, and new records for a key may hash to a different partition, which Kafka’s documentation warns can disturb consumers that rely on key placement.
Offsets
A consumer’s position in a partition is a single number, the offset of the next record to read. The group saves it periodically, so a restarted consumer resumes from the saved offset instead of the start. Because reads do not delete anything, an offset can also be moved back to read old records again, within the topic’s retention.
Consumer groups
Consumers that share a group id form a group, with these rules.
- Each partition is read by exactly one consumer in the group at a time. A consumer may read several partitions.
- Partitions are the unit of parallelism, so a topic with 3 partitions keeps at most 3 consumers of one group busy. A fourth consumer in the group sits idle.
- Different groups are independent. Each has its own offsets and reads every record.
When a consumer joins, leaves or crashes, the group coordinator reassigns partitions, which can briefly interrupt consumption. Kafka 4.0 introduced a new rebalance protocol with less disruption than the classic one.
The catch
A partition is shared by all its keys. If a consumer must keep order and stops on one failing record, every other key in that partition waits behind it, not just the failing one. The partition count also sets the ceiling on parallelism and is awkward to change later, so choose it with growth in mind. See message orderingMessage orderingOrder exists only within one key, and only while one consumer handles that key at a time.Opens in a new tab and dead letters and ordered messagesDead letters and ordered messagesA dead-lettered message leaves the messages after it running on state that never happened.Opens in a new tab.
Sources
- Introduction to Apache Kafka, Apache Kafka · accessed June 12, 2026
- Design, Apache Kafka documentation · accessed June 12, 2026
- Kafka Consumer Design, Confluent Documentation · accessed June 12, 2026
- Basic Kafka Operations, Apache Kafka documentation · accessed June 12, 2026