Skip to content

PIP-120 : Enable client memory limit controller by default - #13344

Merged
merlimat merged 2 commits into
apache:masterfrom
HQebupt:pip-120
Jan 22, 2022
Merged

PIP-120 : Enable client memory limit controller by default#13344
merlimat merged 2 commits into
apache:masterfrom
HQebupt:pip-120

Conversation

@HQebupt

@HQebupt HQebupt commented Dec 15, 2021

Copy link
Copy Markdown
Contributor

Fixes #13306

Motivation

See #13306

Modifications

Enable the MemeoryLimitController. The memoryLimitBytes default is 64M which is easier to control than the maxPendingMessages.

The default 64M has a good performance in produce throughput in our perf test. I am going to post the performance result here.

Verifying this change

  • Make sure that the change passes the CI checks.

This change is a trivial rework / code cleanup without any test coverage.

Does this pull request potentially affect one of the following parts:

If yes was chosen, please highlight the changes

  • Dependencies (does it add or upgrade a dependency): (no)
  • The public API: (no)
  • The schema: (no)
  • The default values of configurations: (no)
  • The wire protocol: (no)
  • The rest endpoints: (no)
  • The admin cli options: (no)
  • Anything that affects deployment: (no)

Documentation

Check the box below and label this PR (if you have committer privilege).

Need to update docs?

  • doc

    (There is description in the configuration modification)

@merlimat merlimat 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.

Let's wait until PIP is accepted before merging

* it will keep in memory (direct memory pool) all the messages in the pending queue.
*
* <p>Default is 1000.
* <p>Default is 0, disable the pending messages check.

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.

We should also deprecate maxPendingMessagesAcrossPartitions() (and setting it to 0 by default), because memory limit is a better approach to limit the max amount of memory.

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.

Done. The maxPendingMessagesAcrossPartitions and maxPendingMessages are deprecated.

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.

Oh, but let's not deprecate this one (maxPendingMessages), since there will still be legitimate reasons to set a max number of 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.

OK, done.

@merlimat merlimat added this to the 2.10.0 milestone Dec 15, 2021
@github-actions

Copy link
Copy Markdown

@HQebupt:Thanks for your contribution. For this PR, do we need to update docs?
(The PR template contains info about doc, which helps others know more about the changes. Can you provide doc-related info in this and future PR descriptions? Thanks)

@hezhangjian

Copy link
Copy Markdown
Member

the test org.apache.pulsar.client.impl.ProducerBuilderImplTest#testProducerBuilderImplWhenMaxPendingMessagesAcrossPartitionsPropertyIsInvalid need to be modified too

@HQebupt

HQebupt commented Dec 16, 2021

Copy link
Copy Markdown
Contributor Author

the test org.apache.pulsar.client.impl.ProducerBuilderImplTest#testProducerBuilderImplWhenMaxPendingMessagesAcrossPartitionsPropertyIsInvalid need to be modified too

@shoothzj Good suggestion. Done. 👍

@HQebupt

HQebupt commented Dec 16, 2021

Copy link
Copy Markdown
Contributor Author

@HQebupt:Thanks for your contribution. For this PR, do we need to update docs?
(The PR template contains info about doc, which helps others know more about the changes. Can you provide doc-related info in this and future PR descriptions? Thanks)

Yes

@HQebupt

HQebupt commented Dec 16, 2021

Copy link
Copy Markdown
Contributor Author

/pulsarbot run-failure-checks

@Anonymitaet

Copy link
Copy Markdown
Member

Hi @HQebupt When submitting a PR, please provide doc related info in the PR description by ticking the box or labeling a PR directly, so that Bot will recognize the info and then label the PR correctly, or else Bot can not recognize the info and then label the PR with the doc-info-missing label. More info see https://docs.google.com/document/d/1Qw7LHQdXWBW9t2-r-A7QdFDBwmZh6ytB4guwMoXHqc0/edit#

I've labeled this PR with doc, please pay attention next time, thanks.

@Anonymitaet Anonymitaet added doc Your PR contains doc changes, no matter whether the changes are in markdown or code files. and removed doc-label-missing labels Dec 16, 2021
@HQebupt

HQebupt commented Dec 16, 2021

Copy link
Copy Markdown
Contributor Author

Hi @HQebupt When submitting a PR, please provide doc related info in the PR description by ticking the box or labeling a PR directly, so that Bot will recognize the info and then label the PR correctly, or else Bot can not recognize the info and then label the PR with the doc-info-missing label. More info see https://docs.google.com/document/d/1Qw7LHQdXWBW9t2-r-A7QdFDBwmZh6ytB4guwMoXHqc0/edit#

I've labeled this PR with doc, please pay attention next time, thanks.

@Anonymitaet Thanks a lot. I realized I did not find the right way.

@HQebupt

HQebupt commented Dec 16, 2021

Copy link
Copy Markdown
Contributor Author

/pulsarbot run-failure-checks

@HQebupt

HQebupt commented Dec 18, 2021

Copy link
Copy Markdown
Contributor Author

/pulsarbot run-failure-checks

@HQebupt
HQebupt requested a review from merlimat December 18, 2021 07:07
@yangl

yangl commented Dec 23, 2021

Copy link
Copy Markdown
Contributor

@HQebupt @merlimat There's no problem setting the memoryLimit by default, but I don't think it's appropriate to deprecate maxPendingMessages right now.

@merlimat

Copy link
Copy Markdown
Contributor

@yangl You're right, we shouldn't deprecate the maxPendingMessages

@HQebupt
HQebupt force-pushed the pip-120 branch 2 times, most recently from 2874be4 to 2db2264 Compare December 23, 2021 12:33
@HQebupt

HQebupt commented Dec 23, 2021

Copy link
Copy Markdown
Contributor Author

Good, let me revert it. I keep the default value as 0.

@HQebupt

HQebupt commented Dec 24, 2021

Copy link
Copy Markdown
Contributor Author

/pulsarbot run-failure-checks

@merlimat
merlimat merged commit 11bfc0e into apache:master Jan 22, 2022
@HQebupt

HQebupt commented Jan 22, 2022

Copy link
Copy Markdown
Contributor Author

Thanks @merlimat

codelipenghui added a commit to codelipenghui/incubator-pulsar that referenced this pull request Apr 24, 2022
…ents

### Motivation

After apache#13344, we have changed the default value of maxPendingMessagesAcrossPartitions to `0`,
for the performance producer, it will always apply the default value of maxPendingMessagesAcrossPartitions
while creating producers, so it will always use `0` for maxPendingMessagesAcrossPartitions.

But we have a check here https://github.com/apache/pulsar/blob/0a91196dcc4d31ae647867ed319b8c1af0cb93c6/pulsar-client/src/main/java/org/apache/pulsar/client/impl/conf/ProducerConfigurationData.java#L138-L142

This will lead the performance producer not able to create if users only set `-o` option

```
06:32:49.628 [pulsar-perf-producer-exec-1-1] ERROR org.apache.pulsar.testclient.PerformanceProducer - Got error
    java.lang.IllegalArgumentException: maxPendingMessagesAcrossPartitions needs to be >= maxPendingMessages
    	at org.apache.pulsar.shade.com.google.common.base.Preconditions.checkArgument(Preconditions.java:145) ~[pulsar-client-admin-2.10.0.2.jar:2.10.0.2]
    	at org.apache.pulsar.client.impl.conf.ProducerConfigurationData.setMaxPendingMessagesAcrossPartitions(ProducerConfigurationData.java:138) ~[pulsar-client-admin-2.10.0.2.jar:2.10.0.2]
    	at org.apache.pulsar.client.impl.ProducerBuilderImpl.maxPendingMessagesAcrossPartitions(ProducerBuilderImpl.java:148) ~[pulsar-client-admin-2.10.0.2.jar:2.10.0.2]
    	at org.apache.pulsar.testclient.PerformanceProducer.runProducer(PerformanceProducer.java:600) ~[pulsar-testclient-2.10.0.2.jar:2.10.0.2]
    	at org.apache.pulsar.testclient.PerformanceProducer.lambda$main$1(PerformanceProducer.java:464) ~[pulsar-testclient-2.10.0.2.jar:2.10.0.2]
    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_332]
    	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_332]
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_332]
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_332]
    	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-common-4.1.74.Final.jar:4.1.74.Final]
    	at java.lang.Thread.run(Thread.java:750) [?:1.8.0_332]
```

### Modification

Change the performance producer to only call `.maxPendingMessagesAcrossPartitions()` if it presents.

### Verification

Added new test to only use `-o` to start the performance producer, use a consumer to consume data from
the topic to make sure the performance producer has been created successfully.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc Your PR contains doc changes, no matter whether the changes are in markdown or code files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PIP-120: Enable client memory limit by default

6 participants