Wrap consumer.poll() for KafkaConsumer iteration #1902
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Now that heartbeats have been moved to a background thread, the pythonic iterator can just wrap
consumer.poll()
and no longer needs to worry about breaking from iteration to support sending background requests. With this approach, some consumers may need to tweakmax_poll_records
and/ormax_poll_interval_ms
, such that consumer's average per-record processing time * max_poll_records < max_poll_interval_ms. Defaults remain at 500 max_poll_records and 5mins for max_poll_interval. This should be sufficient for the vast majority of consumers.My local testing suggests that this change fixes consumer performance issues reported in #1888 .
Given the reduction in overall complexity, this change may also improve #1672 (though won't completely fix).
Because this is a relatively significant change to internals, I have added a configuration option to allow reverting back to the <= 1.4.6 iterator logic:
This change is