oneby-wang opened a new pull request, #24867:
URL: https://github.com/apache/pulsar/pull/24867

   ### Motivation
   
   There no independent `receiverQueueSize` config for single partition 
consumer in `MultiTopicsConsumerImpl` and `PatternMultiTopicsConsumerImpl`. 
Although `maxTotalReceiverQueueSizeAcrossPartitions` config can limit in-memory 
messages of a single topic with multi-partitions, but it can't limit in-memory 
messages of multi-topics.
   
   For example, if we subscribe to a regex pattern that matches 1000 
non-partitioned topics. Before this PR, each non-partitioned topic consumer's 
`receiverQueueSize` is 1000(`ConsumerImpl` uses the same `receiverQueueSize` 
value as `PatternMultiTopicsConsumerImpl`), the max messages in memory is 1000 
+ 1000 * 1000 = 1001000. Let's ignore the insignificant number 1000, if each 
message size is 8Kb, then we need 1000000 * 8Kb = 7,812.5MB memory to boot our 
application in catch-up read situation, which is unnecessary.
   
   
https://github.com/apache/pulsar/blob/e6560657e20d30103f2f01c3a24600dad1ba9ab6/pulsar-client/src/main/java/org/apache/pulsar/client/impl/MultiTopicsConsumerImpl.java#L236-L249
   
   For backward compatibility, add 
`multiTopicsSinglePartitionReceiverQueueSizeEnable` switch, the default value 
is set to false.
   
   ### Modifications
   
   Add independent `multiTopicsSinglePartitionReceiverQueueSize` config for 
single consumer in `MultiTopicsConsumerImpl` to reduce memory consumption.
   
   ### Verifying this change
   
   - [ ] Make sure that the change passes the CI checks.
   
   ### Does this pull request potentially affect one of the following parts:
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   *If the box was checked, please highlight the changes*
   
   - [ ] Dependencies (add or upgrade a dependency)
   - [ ] The public API
   - [ ] The schema
   - [ ] The default values of configurations
   - [ ] The threading model
   - [ ] The binary protocol
   - [ ] The REST endpoints
   - [ ] The admin CLI options
   - [ ] The metrics
   - [ ] Anything that affects deployment
   
   ### Documentation
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ] `doc` <!-- Your PR contains doc changes. -->
   - [ ] `doc-required` <!-- Your PR changes impact docs and you will update 
later -->
   - [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
   - [ ] `doc-complete` <!-- Docs have been already added -->
   
   ### Matching PR in forked repository
   
   PR in forked repository: https://github.com/oneby-wang/pulsar/pull/7
   
   <!--
   After opening this PR, the build in apache/pulsar will fail and instructions 
will
   be provided for opening a PR in the PR author's forked repository.
   
   apache/pulsar pull requests should be first tested in your own fork since 
the 
   apache/pulsar CI based on GitHub Actions has constrained resources and quota.
   GitHub Actions provides separate quota for pull requests that are executed 
in 
   a forked repository.
   
   The tests will be run in the forked repository until all PR review comments 
have
   been handled, the tests pass and the PR is approved by a reviewer.
   -->


-- 
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