max.poll.interval.ms sets the maximum time a Kafka consumer may take between successful KafkaConsumer.poll() calls. If record processing exceeds this interval, Kafka considers the consumer inactive and triggers a group rebalance. section 4.3 section 4.3.1
Follow the consumer loop to reason about the setting:
- KafkaConsumer.poll(Duration) waits for records, then returns a batch to the application. section 4.3.1
- Application code processes every returned record before calling poll() again. section 4.3.1
- The entire processing interval must finish before max.poll.interval.ms expires; the default described here is five minutes. section 4.3.1
- If processing runs too long, improve the processing code or reduce max.poll.records below its described default of 500. section 4.3.1
Five-second polls with longer processing
A consumer can call poll(Duration.ofSeconds(5)) while processing the returned ConsumerRecords. The five-second argument controls how long poll waits for records; max.poll.interval.ms controls how long processing may delay the next poll. section 4.3.1
Figure 4.8 The max.poll.interval.ms configuration specifies how long a consumer may take between calls to KafkaConsumer.poll() before the consumer is considered inactive and removed from the consumer group.
Use the timeline figure to see when a consumer becomes inactive and is removed from its consumer group. section 4.3.1
