Skip to main content
InterviewHubPRO
Section Overview
Q49

Question 49 of 50

Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

98%
Apache Kafka Streaming (50 Qs)•Part 3: Advanced Internals, Scale & Production Architecture (Senior / Lead)

Debugging Stalled Consumers: Diagnosing `CommitFailedException`, `poll()` timeout (`max.poll.interval.ms`), and heartbeat threads.

senior LevelCode ExampleSystem Design

In Simple Words: When consumers crash with:

sql
org.apache.kafka.clients.consumer.CommitFailedException: Offset commit cannot be completed since the group has already rebalanced and assigned the partitions to another member.
  • Root Cause: The consumer took longer to process a batch of records than max.poll.interval.ms (default 5 minutes). Kafka assumed the consumer was dead and triggered a rebalance.
  • Fix:
    1. Decrease max.poll.records (e.g. from 500 down to 50) so each batch finishes well within the interval.
    2. Increase max.poll.interval.ms to accommodate long-running processing tasks.
    3. Separate heavy processing onto background threads while the main thread calls poll() promptly.