Share Groups and Kafka Queues
Share groups provide queue-style record processing in Apache Kafka. Consumers in a share group cooperatively process records without assigning each partition exclusively to one consumer.
KIP-932 introduced share groups as a preview in Kafka 4.1. They became production-ready in Kafka 4.2. Use share groups for independent work items that can be processed concurrently. Use a traditional consumer group when partition ordering, direct offset control, or transactional consume-process-produce semantics are required.
Why Share Groups Exist
Section titled “Why Share Groups Exist”A consumer group assigns each partition to one group member at a time. This preserves partition order, but it also limits active consumers to the number of partitions. Increasing the partition count solely to obtain more workers changes key distribution and increases cluster overhead.
A share group removes that one-partition-to-one-member constraint. Multiple members can acquire records from the same partition, so worker concurrency can exceed the partition count.
| Characteristic | Consumer group | Share group |
|---|---|---|
| Unit assigned to a member | Partition | Acquired records from one or more partitions |
| Members per partition | One active member | Multiple members |
| Maximum useful workers | Bounded by partition count | Can exceed partition count |
| Ordering | Partition order can be preserved | Strict partition order is not guaranteed |
| Progress tracking | Committed offset per partition | Broker-managed record state and share-partition start offset |
| Failure recovery | Partition reassignment and offset replay | Acquisition-lock expiry and record redelivery |
| Completion | Offset commit | Implicit or explicit acknowledgement |
| Transactional consume-process-produce | Supported with a transactional producer | Not supported as a replacement for consumer-group transactions |
Separate share groups consume the same topic independently, just as separate consumer groups do. Within one share group, each record is delivered to one member at a time.
Record Acquisition
Section titled “Record Acquisition”When a share consumer polls, the broker acquires available records for that member. An acquisition lock prevents another member of the same share group from receiving those records while they are being processed.
The default lock duration is 30 seconds. The group-level share.record.lock.duration.ms setting controls the duration within the broker’s configured minimum and maximum. If processing takes longer, an explicit-mode consumer can renew the lock.
| Record state | Meaning | Next action |
|---|---|---|
| Available | The record can be delivered | A poll acquires it for one member |
| Acquired | One member holds a time-limited lock | Accept, release, reject, renew, or allow the lock to expire |
| Acknowledged | Processing completed successfully | Terminal state; the group does not redeliver it |
| Archived | Processing was rejected or the delivery limit was reached | Terminal state; eligible for a configured Kafka 4.4+ DLQ |
The broker limits the number of acquired records per topic-partition and share group. When the limit is reached, fetches pause for that partition until acknowledgements or expired locks reduce the number of acquired records. This bounds in-flight state and prevents failed consumers from blocking delivery indefinitely.
Acknowledgement Modes
Section titled “Acknowledgement Modes”The share.acknowledgement.mode client setting selects implicit or explicit acknowledgement.
Implicit Acknowledgement
Section titled “Implicit Acknowledgement”Implicit mode is the default. Polling again implicitly accepts records returned by the previous poll and commits those acknowledgements asynchronously. Applications can use commitSync() or commitAsync() when they need an explicit acknowledgement-commit point for the batch.
Implicit mode is concise, but every record in the batch receives the same successful outcome. Use it only when the application finishes the entire batch before polling again.
Explicit Acknowledgement
Section titled “Explicit Acknowledgement”Explicit mode lets the application choose an outcome for each record before the next poll:
| Acknowledgement | Result |
|---|---|
ACCEPT | Mark processing successful; do not redeliver |
RELEASE | Make the record available for another delivery attempt |
REJECT | Mark the record unprocessable; do not attempt normal delivery again |
RENEW | Extend the acquisition lock while processing continues |
If the consumer does nothing, the acquisition lock expires and the record becomes available again. A crash can therefore cause redelivery. Handlers should remain idempotent even when using ACCEPT.
Delivery Attempts and Poison Records
Section titled “Delivery Attempts and Poison Records”The broker counts delivery attempts for each record. share.delivery.count.limit controls how many attempts a share group permits, within cluster-defined bounds.
A record is archived when it is rejected or released after reaching the delivery limit. In Kafka 4.4, an archived record can be routed to a broker-managed dead-letter queue when:
- the cluster feature level is at least
share.version=2; - the share group has a DLQ topic configured; and
- the DLQ topic is automatically created or explicitly enabled for share-group DLQ writes.
Without a configured DLQ, archived records are no longer delivered to the share group but are not copied elsewhere. See Dead Letter Queues for the complete behavior and configuration model.
Starting Position and Replay
Section titled “Starting Position and Replay”Share consumers do not use auto.offset.reset, seek(), or consumer-group offset commits. The share group’s share.auto.offset.reset configuration determines the initial position when no share-group state exists.
Administrators can reset the offsets of an inactive share group with kafka-share-groups.sh. Kafka 4.4 can also initialize share-group offsets from a file, including offsets exported from an inactive consumer group. These are administrative recovery and migration operations, not per-consumer replay controls.
Share-group progress is stored in the automatically created __share_group_state internal topic. Its default replication and minimum-ISR settings assume at least three brokers. Development clusters with fewer brokers must adjust the corresponding broker settings before first use.
Delivery Semantics
Section titled “Delivery Semantics”Share groups provide controlled at-least-once processing when failed or timed-out records are released for redelivery. They do not make an external side effect atomic with a record acknowledgement.
Design share consumers to handle duplicates:
- Use a stable event or command ID as an idempotency key.
- Make database writes conditional or use uniqueness constraints.
- Renew the acquisition lock for long-running work rather than allowing concurrent redelivery.
- Reject deterministic poison records instead of retrying indefinitely.
- Configure and monitor a DLQ when records must remain available for investigation.
Do not use a share group when an application depends on strict per-key order or Kafka transactions that atomically publish output and commit consumer-group offsets. See Delivery Semantics for those patterns.
Version Boundaries
Section titled “Version Boundaries”| Kafka version | Share-group status |
|---|---|
| 4.0 and earlier | Not available |
| 4.1 | Preview; enabled with share.version=1 |
| 4.2 | Production-ready core feature set, including lock renewal and share-group lag metrics |
| 4.3 | Additional dynamic limits for delivery count, record locks, and assignment intervals |
| 4.4 | Broker-managed DLQs with share.version=2; offset initialization from a file |
Mark examples and operational instructions with their minimum Kafka version. In particular, do not present broker-managed DLQs as Kafka 4.2 behavior: they require Kafka 4.4 and share.version=2.
Related Documentation
Section titled “Related Documentation”- Concepts Overview - Consumer groups and share groups in the Kafka model
- Dead Letter Queues - Application, Connect, Streams, and share-group DLQs
- Group Configuration - Dynamic consumer, share, and Streams group settings
- Share-Group Protocol APIs - Wire protocol and API versions
- Delivery Semantics - At-most-once, at-least-once, and exactly-once processing