Skip to content

KAFKA-6743 ConsumerPerformance fails to consume all messages #4818

Merged
hachikuji merged 9 commits into
apache:trunkfrom
rootex-:KAFKA-6743_ConsumerPerformance_export_polling_loop_timeout_option_to_the_user
Jun 2, 2018
Merged

KAFKA-6743 ConsumerPerformance fails to consume all messages #4818
hachikuji merged 9 commits into
apache:trunkfrom
rootex-:KAFKA-6743_ConsumerPerformance_export_polling_loop_timeout_option_to_the_user

Conversation

@rootex-

@rootex- rootex- commented Apr 3, 2018

Copy link
Copy Markdown
Contributor

ConsumerPerformance fails to consume all messages

on topics with large number of partitions due to a relatively short default polling loop timeout (1000 ms) that is not reachable and modifiable by the end user.

Demo

Create a topic of 10 000 partitions, send a 50 000 000 of 100 byte records using kafka-producer-perf-test and consume them using kafka-consumer-perf-test (ConsumerPerformance). You will likely notice that the number of records returned by the kafka-consumer-perf-test is many times less than expected 50 000 000.

This happens due to specific ConsumerPerformance implementation. As the result, in some rough cases it may take a long enough time to process/iterate through the records polled in batches, thus, the time may exceed the default hardcoded polling loop timeout and this is probably not what we want from this utility.

Possible options

  1. Increasing polling loop timeout in ConsumerPerformance implementation. It defaults to 1000 ms and is hardcoded, thus cannot be changed but we could export it as an OPTIONAL kafka-consumer-perf-test parameter to enable it on a script level configuration and available to the end user.
  2. Decreasing max.poll.records on a Consumer config level. This is not a fine option though since we do not want to touch the default settings.

KAFKA-6743: ConsumerPerformance fails to consume all messages on topics with large number of partitions
KIP-281: ConsumerPerformance: Increase Polling Loop Timeout and Make It Reachable by the End User

Result

bin/kafka-consumer-perf-test.sh... --polling-loop-timeout <TIME_IN_MS>

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@rootex- rootex- changed the title KAFKA-6724 ConsumerPerformance resets offsets on every startup KAFKA-6743 ConsumerPerformance resets offsets on every startup Apr 3, 2018
@rootex-
rootex- force-pushed the KAFKA-6743_ConsumerPerformance_export_polling_loop_timeout_option_to_the_user branch from f14792b to 5891628 Compare April 3, 2018 14:57

@hachikuji hachikuji left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch. Left one comment. Also, maybe we can change the title? Does this patch have anything to do with offset reset behavior?

val printMetricsOpt = parser.accepts("print-metrics", "Print out the metrics. This only applies to new consumer.")
val showDetailedStatsOpt = parser.accepts("show-detailed-stats", "If set, stats are reported for each reporting " +
"interval as configured by reporting-interval")
val pollLoopTimeoutOpt = parser.accepts("polling-loop-timeout", "Consumer polling loop timeout.")

@hachikuji hachikuji Apr 3, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The performance tool is part of the public API, so adding new options requires a short KIP.

To be honest, the default timeout of 1 second doesn't make much sense to me. I would probably consider either removing the timeout entirely or at least increasing it to something more substantial (say one minute). If we decide to keep it, we should add a message to indicate that the tool exited before consuming all messages.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jason, thanks a lot for your remark. I'll be back in a while with new KIP.

@rootex- rootex- Apr 4, 2018

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review KIP-278

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I left a few comments on the dev list.

@MosheBlumbergX MosheBlumbergX Apr 5, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the KIP number to show the correct number KIP-281

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hachikuji please, review this one

@MosheBlumbergX thank you!

Waiting for some more feedback on KIP-281, friends.

Thanks

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rootex- Sorry, sent my initial response to the wrong thread. I've replied to the right one now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hachikuji No problem, appreciate for your feedback!

@rootex- rootex- changed the title KAFKA-6743 ConsumerPerformance resets offsets on every startup KAFKA-6743 ConsumerPerformance fails to consume all messages Apr 3, 2018
@hachikuji

Copy link
Copy Markdown
Contributor

@rootex- Thanks for the updates. Can you reply to the KIP thread? Since there haven't been many comments, you can probably go ahead and start a vote.

@rootex-

rootex- commented Apr 16, 2018

Copy link
Copy Markdown
Contributor Author

@hachikuji Thank you for the quick response, just replied to the KIP [DISCUSS] thread. And started the KIP [VOTE] thread

}
if (messagesRead < count)
println(s"WARNING: Exiting before consuming the expected number of messages: timeout ($timeout ms) exceeded. " +
s"Probably too much time spent on processing a polled list of records. Be sure to increase the --timeout option")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Missing "." at the end.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also wonder if this is the right place to print this message. Perhaps this should be outside the while loop?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dhruvilshah3, my bad, thank you for pointing this out. Updated

@dhruvilshah3

Copy link
Copy Markdown
Contributor

Thanks for the PR! Left a minor comment, otherwise LGTM.

@ijuma ijuma added this to the 2.0.0 milestone May 21, 2018
@astubbs

astubbs commented May 29, 2018

Copy link
Copy Markdown
Contributor

Relates to #4082

@hachikuji hachikuji left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rootex- I think you have enough binding votes for this KIP, so you can close the vote. This is small enough that I think we can still get this patch into 2.0.0. I had just one small comment.

val printMetricsOpt = parser.accepts("print-metrics", "Print out the metrics. This only applies to new consumer.")
val showDetailedStatsOpt = parser.accepts("show-detailed-stats", "If set, stats are reported for each reporting " +
"interval as configured by reporting-interval")
val pollLoopTimeoutOpt = parser.accepts("timeout", "Consumer polling loop timeout.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this more descriptive? How about this?

The maximum allowed time between returned records

Also, maybe we can change the name to recordFetchTimeout or something like that?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we also mention that the timeout is in milliseconds? And perhaps also name the variable recordFetchTimeoutMs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dhruvilshah3
@hachikuji

Hello, guys. Sure, I'll take care of that today.

Would you like to apply changes for both the variable name and the UI parameter? If yes, then KIP should be updated too.

Thanks for closing the vote session. Been away for a while, I have more time now.

@hachikuji

Copy link
Copy Markdown
Contributor

@rootex- I went ahead and called the vote. I'm going to go ahead and push a change to this branch to move things along.

@rootex-

rootex- commented Jun 1, 2018

Copy link
Copy Markdown
Contributor Author

@hachikuji Jason, thanks for closing the vote session. I'll push the changes today.

@hachikuji

Copy link
Copy Markdown
Contributor

@rootex- Thanks, I can merge once the changes are ready.

@rootex-

rootex- commented Jun 1, 2018

Copy link
Copy Markdown
Contributor Author

@hachikuji Jason, would you like to apply changes for both the variable name recordFetchTimeoutMs and the UI parameter --record-fetch-timeout? If yes, then KIP should be updated too.

@hachikuji

Copy link
Copy Markdown
Contributor

@rootex- Oh, I was actually referring to the variable pollLoopTimeoutOpt, not the command argument. I think --timeout is fine, but we can mention in the description that it is specified in milliseconds as @dhruvilshah3 suggests.

@rootex-

rootex- commented Jun 2, 2018

Copy link
Copy Markdown
Contributor Author

@hachikuji Jason, thanks for explaining. It's all done now 👌 If everything's fine, let's merge it right away 👍

@hachikuji hachikuji left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the patch! Note that i made a minor tweak to the warning message.

@hachikuji
hachikuji merged commit 1d5f864 into apache:trunk Jun 2, 2018
ying-zheng pushed a commit to ying-zheng/kafka that referenced this pull request Jul 6, 2018
…1] (apache#4818)

This patch implements KIP-281, which adds a configurable timeout to the consumer performance tool with a default value of 10 seconds. The old timeout was hard-coded as 1 second. Additionally, this patch adds a warning message when the tool exits after a timeout rather than returning silently.

Reviewers: Dhruvil Shah <dhruvil@confluent.io>, Jason Gustafson <jason@confluent.io>
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

Successfully merging this pull request may close these issues.

6 participants