Apache Kafka Tutorial 0/111 lessons ~6 min read Lesson 25
Consumer Configuration
What is Consumer Configuration?
Course progress0%
Focus
9 guided sections
Practice signal
Examples included
Career prep
Foundation builder
Introduction
What is Consumer Configuration? Consumer config controls group identity, offset reset, commit behavior, max poll size, session timeout, and partition assignment strategy.
Understanding the topic
What happens — Consumer Configuration:
- group.id identifies the consumer group.
- enable.auto.commit=false for manual control.
- auto.offset.reset for new groups.
- max.poll.interval.ms limits processing time.
| Term | Description |
|---|---|
| Consumer group | A set of consumers sharing work — each partition goes to at most one member at a time. |
| Offset | Position in a partition log — where this consumer last read. |
| Poll loop | consumer.poll() fetches batches of records; keep processing faster than max.poll.interval.ms. |
| Commit | Saving offset to Kafka after processing — sync or async, manual or auto. |
| Lag | Difference between latest offset and consumer offset — key health metric. |
Visual explanation
Pipeline view:
text
Consumer polls records from topic partitions↓Process business logic (DB, API, etc.)↓Commit offset after success↓Monitor consumer lag
Step-by-step explanation
- Subscribe — Consumer joins a group and receives partition assignments.
- Poll — Fetch records in batches with consumer.poll().
- Process — Run business logic for each record.
- Commit — Save offset after successful side effects.
- Repeat — Continue polling; rebalance if group membership changes.
Informative example
Example:
bash
group.id=inventory-serviceenable.auto.commit=falseauto.offset.reset=earliestmax.poll.records=500session.timeout.ms=45000partition.assignment.strategy=org.apache.kafka.clients.consumer.CooperativeStickyAssignor
Execution workflow
1Consumer Configuration workflow
1 / 5Subscribe
Consumer joins a group and receives partition assignments.
Best practices
- Use manual commits for critical side effects.
- Make consumers idempotent with event IDs or unique constraints.
- Keep processing under max.poll.interval.ms or use pause/resume patterns.
- Send poison messages to DLT with failure metadata.
Common mistakes
- Committing before database writes complete.
- Scaling consumers beyond partition count and expecting more throughput.
- Blocking the poll loop with slow downstream calls.
Summary
Consumer Configuration — Commit offsets only after successful processing; make handlers idempotent; monitor lag per partition.
Ready to mark this lesson complete?Track your journey across the entire course.