Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bulk Pubsub Optimization Opportunities #3808

Merged
merged 10 commits into from
Oct 11, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,10 @@ In the example above, `bulkSubscribe` is _optional_. If you use `bulkSubscribe`,
- `enabled` is mandatory and enables or disables bulk subscriptions on this topic
- You can optionally configure the max number of messages (`maxMessagesCount`) delivered in a bulk message.
Default value of `maxMessagesCount` for components not supporting bulk subscribe is 100 i.e. for default bulk events between App and Dapr. Please refer [How components handle publishing and subscribing to bulk messages]({{< ref pubsub-bulk >}}).
If a component supports bulk subscribe, then default value for this parameter can be found in that component doc. Please refer [Supported components]({{< ref pubsub-bulk >}}).
If a component supports bulk subscribe, then default value for this parameter can be found in that component doc.
- You can optionally provide the max duration to wait (`maxAwaitDurationMs`) before a bulk message is sent to the app.
Default value of `maxAwaitDurationMs` for components not supporting bulk subscribe is 1000 i.e. for default bulk events between App and Dapr. Please refer [How components handle publishing and subscribing to bulk messages]({{< ref pubsub-bulk >}}).
If a component supports bulk subscribe, then default value for this parameter can be found in that component doc. Please refer [Supported components]({{< ref pubsub-bulk >}}).
If a component supports bulk subscribe, then default value for this parameter can be found in that component doc.

The application receives an `EntryId` associated with each entry (individual message) in the bulk message. This `EntryId` must be used by the app to communicate the status of that particular entry. If the app fails to notify on an `EntryId` status, it's considered a `RETRY`.

Expand Down Expand Up @@ -473,9 +473,37 @@ public class BulkMessageController : ControllerBase
{{< /tabs >}}
## How components handle publishing and subscribing to bulk messages

Some pub/sub brokers support sending and receiving multiple messages in a single request. When a component supports bulk publish or subscribe operations, Dapr runtime uses them to further optimize the communication between the Dapr sidecar and the underlying pub/sub broker.

For components that do not have bulk publish or subscribe support, Dapr runtime uses the regular publish and subscribe APIs to send and receive messages one by one. This is still more efficient than directly using the regular publish or subscribe APIs, because applications can still send/receive multiple messages in a single request to/from Dapr.
When talking about event publish/subscribe, there are two kind of network transfers involved.
hhunter-ms marked this conversation as resolved.
Show resolved Hide resolved
1. From/To *App* To/From *Dapr*.
2. From/To *Dapr* To/From *Pubsub Broker*.
hhunter-ms marked this conversation as resolved.
Show resolved Hide resolved

And, these are the opportunities where optimization is possible for multiple Single calls v/s Bulk. Here, optimization means that Bulk calls are sent, which reduce number of overall calls and thus increased throughput ad better latency.
hhunter-ms marked this conversation as resolved.
Show resolved Hide resolved
hhunter-ms marked this conversation as resolved.
Show resolved Hide resolved

On enabling Bulk Publish and/or Bulk Subscribe, Point 1 i.e. From/To *App* To/From *Dapr* is optimized for All components (depending on whether either one of Bulk Publish/ Bulk Subscribe OR Both are enabled).
hhunter-ms marked this conversation as resolved.
Show resolved Hide resolved

But, optimization of Point 2 i.e. From/To *Dapr* To/From *Pubsub Broker* would depend on a number of factors, i.e. if Broker inherently supports Bulk Publish/Subscribe and if Dapr component is updated to support Batching. Currently, following components are updated to support this level of optimization:
hhunter-ms marked this conversation as resolved.
Show resolved Hide resolved
<table width="100%">
<tr>
<th>Component</th>
<th>Bulk Publish</th>
<th>Bulk Subscribe</th>
</tr>
<tr>
<td>Kafka</td>
<td>Yes</td>
<td>Yes</td>
</tr>
<tr>
<td>Azure Servicebus</td>
<td>Yes</td>
<td>Yes</td>
</tr>
<tr>
<td>Azure Eventhubs</td>
<td>Yes</td>
<td>Yes</td>
</tr>
</table>
hhunter-ms marked this conversation as resolved.
Show resolved Hide resolved

## Demos

Expand Down
Loading