michaeljmarshall opened a new pull request, #17686:
URL: https://github.com/apache/pulsar/pull/17686

   ### Motivation
   
   Currently, when using entry filters, filtered out messages do not count 
against the rate limit. Therefore, a subscription that is completely filtered 
will never be throttled due to rate limiting. When the messages are delivered 
to the consumer for a filtered subscription, those messages will count against 
the rate limit, and in that case, the message filtering can be throttled 
because the check to delay `readMoreEntries()` happens before message 
filtering. Therefore, the rate limit will essentially be increased as a 
function of the percent of messages let through the filter (some quick math is 
that the new rate is likely `dispatchRate * (1 / percentDelivered)`, where 
percent delivered is a percent as a decimal.
   
   It's possible that some use cases prefer this behavior, but in my case, I 
think it'd be valuable to include these filtered messages in the dispatch 
throttling because these messages still cost the broker network, memory, and 
cpu. This PR adds a configuration to count filtered out messages towards 
dispatch rate limits for the broker, the topic, and the subscription.
   
   ### Modifications
   
   * Add configuration named `dispatchThrottlingForFilteredEntriesEnabled`. 
Default it to false so we maintain the original behavior. When true, count 
filtered messages against rate limits.
   * Refactor the code to `acquirePermitsForDeliveredMessages` so that it is in 
the `AbstractBaseDispatcher`, which makes it available to the entry filtering 
logic.
   
   ### Verifying this change
   
   A new test is added as part of this PR.
   
   ### Does this pull request potentially affect one of the following parts:
   
   This PR introduces a new config while maintaining the current behavior.
   
   ### Documentation
   
   - [x] `doc-not-needed` 
   Config docs are auto-generated.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to