liveBook · Manning

Max.poll.interval.ms

As explained in Kafka Streams in Action, Second Edition

max.poll.interval.ms is the maximum allowed time between successful Kafka consumer poll calls before the consumer is considered unresponsive and removed from its group.

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.
figure

Use the timeline figure to see when a consumer becomes inactive and is removed from its consumer group. section 4.3.1

How Kafka Streams in Action, Second Edition covers it

How deep it goes
Explains the poll-processing loop, default five-minute interval, rebalance consequence, and two practical tuning responses.
Examples
Uses a five-second poll timeout, per-record processing, a five-minute default, and a 500-record max.poll.records default.
What it assumes
Assumes familiarity with KafkaConsumer.poll() and consumer records while introducing inactivity and rebalancing consequences.
What you can do after
Operate/configure Kafka consumers by diagnosing slow processing and reducing max.poll.records when needed.
How it connects
Links KafkaConsumer.poll(), consumer groups, rebalancing, and max.poll.records.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kafka Streams in Action, Second Edition. The section links point to the parts of the book it draws on.