-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-18371][Streaming] Spark Streaming backpressure generates batch with large number of records #17774
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
Conversation
|
Code looks sound. Could you add or modify a test to illustrate/verify? |
srowen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CC @koeninger
The thing is, it seems like rates are intentionally not floating point here, but I don't know the history of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Given your change, I think double becomes more reasonable than float.
|
How do you read 0.1 of a kafka message for a given partition of a given batch? Ultimately the floor for a rate limit, assuming one is set, needs to be 1 message per partition per batch, not a fraction, which is why it's a long. If you want to delay that conversion by keeping it as a double as long as possible, that makes sense, but the lines like (secsPerBatch * limit).toLong probably need attention too. |
|
Thanks for your valuable feedback. I added tests as suggested by @JasonMWhite and used |
|
To run tests or debug using IntelliJ: |
|
@arzt It's entirely possible to have batch times less than a second, and I'm not sure I agree that the absolute number of messages allowable for a partition should ever be zero. So to put this another way, right now effectiveRateLimitPerPartition is a Map[TopicPartition, Long], which matches the return value of the function maxMessagesPerPartition. You're wanting to change effectiveRateLimitPerPartition to a Map[TopicPartition, Double], which is probably a good idea, and should fix the bug around treating a very small rate limit as no limit. But it still needs to be converted to Map[TopicPartition, Long] before returning. Calling .toLong is probably not the right thing to do there, because 0.99 will get truncated to 0. I think one message per partition per batch is the minimum reasonable rate limit, otherwise particular partitions may not make progress. The relative lag calculation might take care of that in future batches, but it still seems questionable, even if it's a corner case. |
|
@koeninger I agree that assuming a long batch size is wrong, not sure whether it even matters. |
|
Have you read the function def clamp?
Rate limit of 1 should not imply an attempt to grab 1 message even if it
doesn't exist.
…On Apr 27, 2017 11:01, "Sebastian Arzt" ***@***.***> wrote:
@koeninger <https://github.com/koeninger> I agree that assuming a long
batch size is wrong, not sure whether it even matters.
But what if for one partition there is no lack in the current batch? Then
fetching 1 message for this partition from kafka, is you suggest, would
fail. So here zero makes sense in my eyes. This is also the old behaviour
if rate > 1 and lag == 0 here
<https://github.com/apache/spark/blob/master/external/kafka-0-8/src/main/scala/org/apache/spark/streaming/kafka/DirectKafkaInputDStream.scala#L107>
.
Further, I think that truncating 0.99 to 0 messages per partition is also
the right thing to do, as one cannot be sure that there is one message
available if (secsPerBatch * limit) < 1.0. And as you say, in a future
batch it is very like to become greater than 1.0.
Do you agree?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#17774 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAGAB1X8NCNqECUlx9X54DSAmbnHmHdAks5r0LvggaJpZM4NJAVA>
.
|
|
I think @koeninger's suggestion is valid. Making Setting |
|
I changed the max messages per partition to be at least 1. Agreed? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The actual result should be deterministic, why not check the correct value instead of just not None ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After omitting the case of zero messages per topic, one of the tests is redundant. I removed it from each DirectKafkaStreamSuite.
|
Tests have some fairly repetitive code, but not sure if that's a problem or not. Looks good to me. |
|
LGTM pending jason's comments on tests |
|
Jenkins, ok to test |
|
Test build #76256 has finished for PR 17774 at commit
|
|
Test build #76263 has finished for PR 17774 at commit
|
|
Sorry for being inactive. All good with this? |
|
LGTM |
|
@felixcheung will this be merged? |
|
It's been a while. What can I do to draw some attention to this request? Is this issue not relevant enough? Thanks for reconsideration @felixcheung @brkyvz @zsxwing |
c98b9a4 to
16b9aaf
Compare
|
Test build #78618 has finished for PR 17774 at commit
|
16b9aaf to
29fe32c
Compare
29fe32c to
fddf5e5
Compare
fddf5e5 to
1acbe4c
Compare
|
I am looking forward this one to be merged. we are suffering from the issue it resolved quite badly. It effectively makes the back-pressure not working for us at all. |
|
Jenkins, ok to test |
felixcheung
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pending tests
|
Test build #88226 has finished for PR 17774 at commit
|
|
merged to master |
… with large number of records ## What changes were proposed in this pull request? Omit rounding of backpressure rate. Effects: - no batch with large number of records is created when rate from PID estimator is one - the number of records per batch and partition is more fine-grained improving backpressure accuracy ## How was this patch tested? This was tested by running: - `mvn test -pl external/kafka-0-8` - `mvn test -pl external/kafka-0-10` - a streaming application which was suffering from the issue JasonMWhite The contribution is my original work and I license the work to the project under the project’s open source license Author: Sebastian Arzt <[email protected]> Closes apache#17774 from arzt/kafka-back-pressure.
What changes were proposed in this pull request?
Omit rounding of backpressure rate. Effects:
How was this patch tested?
This was tested by running:
mvn test -pl external/kafka-0-8mvn test -pl external/kafka-0-10@JasonMWhite
The contribution is my original work and I license the work to the project under the project’s open source license