Skip to content

[feat][doc] Add docs for message dispatch throttling - #386

Merged
momo-jun merged 15 commits into
apache:mainfrom
momo-jun:message-dispatch-throttling
Mar 13, 2023
Merged

[feat][doc] Add docs for message dispatch throttling#386
momo-jun merged 15 commits into
apache:mainfrom
momo-jun:message-dispatch-throttling

Conversation

@momo-jun

@momo-jun momo-jun commented Jan 18, 2023

Copy link
Copy Markdown
Contributor

Fixes apache/pulsar#18506

Modifications

  1. Add docs for message dispatch throttling.
  2. Install plugins and configure docusaurus to support math equations.

Thanks @poorbarcode for providing the draft and technical details, and thanks @heesung-sn for the initial review.

More comments on the initial draft review can be found in the the Google doc.

//cc @Anonymitaet @DaveDuggins
FYI - this PR also enables math equations, and you can take the examples for reference.

Preview screenshots:

image

image

image

image

image

image

image

image

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

@momo-jun momo-jun self-assigned this Jan 18, 2023
@momo-jun
momo-jun requested review from tisonkun and urfreespace and removed request for tisonkun January 20, 2023 07:30
@momo-jun

Copy link
Copy Markdown
Contributor Author

Ping @tisonkun and @urfreespace to take a look first, because this PR tends to make changes to the Docusaurus configurations to enable the math equation.

@tisonkun tisonkun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please avoid checking in package-lock.json file. The rest should be fine as long as precommit build passed and your preview locally is correct :)

@momo-jun
momo-jun marked this pull request as ready for review February 3, 2023 09:24
@github-actions

github-actions Bot commented Feb 3, 2023

Copy link
Copy Markdown
Contributor

@momo-jun Please add the following content to your PR description and select a checkbox:

- [ ] `doc` <!-- Your PR contains doc changes -->
- [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
- [ ] `doc-not-needed` <!-- Your PR changes do not impact docs -->
- [ ] `doc-complete` <!-- Docs have been already added -->

@github-actions github-actions Bot added doc Improvements or additions to documentation and removed doc-label-missing labels Feb 3, 2023
@momo-jun

momo-jun commented Feb 8, 2023

Copy link
Copy Markdown
Contributor Author

Ping @poorbarcode @heesung-sn @codelipenghui @gaoran10 for review.

@tisonkun
tisonkun self-requested a review February 8, 2023 02:39

@tisonkun tisonkun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good. Comments inline.

Comment thread docs/concepts-throttling.md Outdated
Comment thread docs/concepts-throttling.md Outdated

- **Limit the allocation of client’s hardware resources at topic/subscription levels**

When there is a large backlog of messages to consume, clients may receive a large amount of data in a short period of time, which monopolizes their computing resources. Since the client has no mechanisms to proactively limit the consumption rate, using the message dispatch throttling feature can also regulate the allocation of the client’s hardware resources.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the client has no mechanisms to proactively limit the consumption rate

Why? Consumer#receive receives one message per call. Client app can define their consume logic.

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.

@poorbarcode can you pls take a look at this question?

@poorbarcode poorbarcode Feb 24, 2023

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.

Hi @tisonkun

Since the client has no mechanisms to proactively limit the consumption rate

Why? Consumer#receive receives one message per call. Client app can define their consume logic.

The code that users consume messages often looks like this:

while ((msg = consumer.receive()) != null){
    doService(msg)
}

Method doService costs more cpu, memory, and other resources than receiving messages. If there is a lot backlog in this topic( perhaps more than one topic ), then these threads of consumers will keep working busy, which puts other services( such as web service ) on the same machine at a disadvantage.

In a standard service, messages tend to be processed asynchronously (not high priority), so there are scenarios where customers need to limit the amount of system resources consumed by consuming messages to keep other services working


**Workaround**

Configuring `preciseDispatcherFlowControl` or `dispatchThrottlingOnBatchMessageEnabled` can mitigate the over-delivery issue. For example, turning on `preciseDispatcherFlowControl` can mitigate the limitation by pre-decrementing the quota using the approximated average message count per entry. See [Throttling configurations](#throttling-configurations) for more details.

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.

If this mitigation also helps the second limitation, please move this to the bottom of this section and mention these configs can help both limitations.

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.

@poorbarcode can this workaround resolve the limitation caused by the second case? I thought the over-delivery limitation can be caused by two cases, and this workaround only serves the first one. Can you please clarify this?

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.

Hi @momo-jun

can this workaround resolve the limitation caused by the second case? I thought the over-delivery limitation can be caused by two cases

Yes, you are right. Thanks for @heesung-sn

Comment thread docs/concepts-throttling.md Outdated
:--------|:------------|:----------|:----------------
Set [broker configurations](#throttling-configurations) or [dynamic broker configurations](admin-api-brokers.md#dynamic-broker-configuration) | <li>`dispatchThrottlingRateInMsg`</li><li>`dispatchThrottlingRateInByte`</li> | <li>`dispatchThrottlingRatePerTopicInMsg`</li><li>`dispatchThrottlingRatePerTopicInByte`</li><br />It applies to all topics in the cluster. | <li>`dispatchThrottlingRatePerSubscriptionInMsg`</li><li>`dispatchThrottlingRatePerSubscriptionInByte`</li><br />It applies to all subscriptions in the cluster.
Set namespace policies | N/A | Refer to [Configure dispatch throttling for topics](admin-api-namespaces.md#configure-dispatch-throttling-for-topics). | Refer to [Configure dispatch throttling for subscriptions](admin-api-namespaces.md#configure-dispatch-throttling-for-subscription).
Set topic policies | N/A | Refer to [Set topic-level dispatch rate](https://pulsar.apache.org/admin-rest-api/#operation/persistent_setDispatchRate). | Refer to [Set subscription-level dispatch rate](https://pulsar.apache.org/admin-rest-api/#operation/getSubscriptionLevelDispatchRate).<br />It applies to all subscriptions in a topic.

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.

Please confirm if these links are in the correct MD format.

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.

This link validity has a dependency on apache/pulsar#19193. I'll double-check it after apache/pulsar#19193 is merged.

@poorbarcode poorbarcode Feb 24, 2023

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.

Hi @momo-jun

Sorry, I think this PR will be terminated because I have found a better solution, and I will submit a new PR next week or later.

@heesung-sn

Thanks.

@momo-jun momo-jun Feb 26, 2023

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.

@poorbarcode Thanks for letting us know. Keep us posted when the link is ready.

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.

Are you going to develop a new feature? Keep us posted. I'll close this PR when the new one is ready.

No. I will just rewrite the PR apache/pulsar#19193.

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.

Hi @momo-jun @heesung-sn

I have updated the changes in apache/pulsar#19193 to solve the admin API link conflict. Please help review it when you have time.

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.

Hi @momo-jun

apache/pulsar#19193 has been merged.

@momo-jun

Copy link
Copy Markdown
Contributor Author

@tisonkun @heesung-sn @codelipenghui do you have any other questions before we merge this PR?


When you set the dispatch rate limit in bytes/throttling-period (`dispatchThrottlingRateInByte`/`ratePeriodInSecond`), the broker calculates $$the \ number \ of \ entries \ to \ read \ from \ bookies$$ in one throttling period through the following equation:

$$

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.

I found there are many symbols $$ and \, it seems that they are not valid markdown symbols.

@momo-jun momo-jun Mar 11, 2023

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.

@gaoran10 Thanks for noticing it. I should have attached all the preview screenshots to make this clear:)

This is a new style to highlight the unknown of the math equation. The preview looks good as follows.

image

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, got it, thanks.

@tisonkun tisonkun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. One inline comment.

Comment thread docs/concepts-throttling.md Outdated
Comment thread docs/concepts-throttling.md Outdated
@momo-jun

Copy link
Copy Markdown
Contributor Author

Confirmed with @poorbarcode, this feature has been available since 2.8.x. I will add the docs to those earlier versions in the next commit.

@momo-jun
momo-jun merged commit 42648bf into apache:main Mar 13, 2023

@heesung-sohn heesung-sohn 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.

lgtm

@Anonymitaet Anonymitaet added this to the 3.0.0 milestone Apr 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Doc] Improve Pulsar Pub/Sub Throttling Doc

7 participants