[feat][doc] Add docs for message dispatch throttling - #386
Conversation
|
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
left a comment
There was a problem hiding this comment.
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 Please add the following content to your PR description and select a checkbox: |
|
Ping @poorbarcode @heesung-sn @codelipenghui @gaoran10 for review. |
tisonkun
left a comment
There was a problem hiding this comment.
Generally looks good. Comments inline.
|
|
||
| - **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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@poorbarcode can you pls take a look at this question?
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@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?
There was a problem hiding this comment.
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
| :--------|:------------|:----------|:---------------- | ||
| 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. |
There was a problem hiding this comment.
Please confirm if these links are in the correct MD format.
There was a problem hiding this comment.
This link validity has a dependency on apache/pulsar#19193. I'll double-check it after apache/pulsar#19193 is merged.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@poorbarcode Thanks for letting us know. Keep us posted when the link is ready.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Hi @momo-jun
apache/pulsar#19193 has been merged.
|
@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: | ||
|
|
||
| $$ |
There was a problem hiding this comment.
I found there are many symbols $$ and \, it seems that they are not valid markdown symbols.
There was a problem hiding this comment.
@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.
|
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. |

Fixes apache/pulsar#18506
Modifications
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:
docdoc-requireddoc-not-neededdoc-complete