-
Notifications
You must be signed in to change notification settings - Fork 137
[fix] Use async back pressure to limit RIP #1621
base: master
Are you sure you want to change the base?
[fix] Use async back pressure to limit RIP #1621
Conversation
The changes make sense. Some improvement areas:
The 2nd point isn't as important as the 1st point where the overall backpressure solution should be considered. Some parts of the existing backpressure solution can be seen in kop/kafka-impl/src/main/java/io/streamnative/pulsar/handlers/kop/KafkaRequestHandler.java Lines 779 to 825 in 10d1d92
If there are multiple independent backpressure solutions on the same channel, that would lead to conflicting behavior. Regarding the overall backpressure solution, it's a major gap in Pulsar and KOP that Netty's asynchronous backpressure for handling outbound traffic (channelWritabilityChanged events). It seems that the solution added in #488 somewhat covers that without using Netty's built-in solution for not overwhelming outbound buffers. |
Codecov Report
@@ Coverage Diff @@
## master #1621 +/- ##
============================================
+ Coverage 14.96% 15.76% +0.80%
- Complexity 592 612 +20
============================================
Files 164 164
Lines 12225 12247 +22
Branches 1120 1123 +3
============================================
+ Hits 1829 1931 +102
+ Misses 10242 10157 -85
- Partials 154 159 +5
|
Thanks for your review @lhotari. I didn't notice that we were already using the auto read, so I'll re-review the solution there as well as at the low and high water mark. |
Motivation
This is a work in progress to make the
KafkaCommandDecoder
use asynchronous backpressure to limit the number of requests in progress. The current code uses synchronous backpressure to block a netty event loop, which is an anti pattern, and can lead to issues with other connections.Modifications
numQueuedRequestsInProgress
to track number of requests. This variable is only updated from the event loop thread, so it does not need to be synchronized in any way.autoRead
when the channel has reached its limit, and enable auto read when it has gone below its limit.Verifying this change
I'll work on adding tests tomorrow.
Documentation
no-need-doc
This is an internal optimization that does not need to be documented.