Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Large CPU usage due to busy waiting by KafkaConsumer.poll() #1383

Closed
braedon opened this issue Feb 16, 2018 · 0 comments
Closed

Large CPU usage due to busy waiting by KafkaConsumer.poll() #1383

braedon opened this issue Feb 16, 2018 · 0 comments

Comments

@braedon
Copy link
Contributor

braedon commented Feb 16, 2018

KafkaConsumer.poll() is effectively busy waiting, as KafkaConsumer._poll_once() doesn't respect timeout_ms.

_poll_once() sets timeout_ms of KafkaClient.poll() to:

min(timeout_ms, self._coordinator.time_to_next_poll())

However, ConsumerCoordinator.time_to_next_poll() returns the time in seconds, not milliseconds. The effective timeout is always much lower than timeout_ms, causing KafkaConsumer.poll() to spin, consuming a lot of CPU.

braedon added a commit to braedon/kafka-python that referenced this issue Feb 16, 2018
ConsumerCoordinator.time_to_next_poll() returns seconds, so need to convert
to milliseconds.

Fixes dpkp#1383
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant