[英]Dapr pub/sub is slow
我用 C# 創建了一個小型性能測試應用程序
使用在我的本地機器上托管 1 個分區的簡單主題,我可以通過 confluent 庫獲得大約 1000 條消息/秒的持續發送速率。
使用 Dapr,我每秒只能收到大約 80-100 條消息。
使用 Dapr:
await client. PublishEventAsync("kafka-pubsub-noauth", "topic1", msg);
ProducedMessages++;
隨着匯合
in the configration : acks=1
// dont know where to set this for Dapr, 0 is a little faster,
// "all" is the same as 1 as i only have one broker
producer.Produce("topic1", msg, KafkaDeliveryHandler);
....
private void KafkaDeliveryHandler(
DeliveryReport<string, CustomMessage> deliveryReport)
{
...
ProducedMessages += 1;
...
}
//Wait at the end to get the DeliveryReports for all produced messages.
發送幾千條消息,花時間,然后划分時間/消息計數。
我現在也已將 pubsub.yaml 組件切換到 Redis 和 RabbitMQ,並且 Dapr PublishEventAsync 的性能似乎是瓶頸,因為我也達到了最大 100-150 條消息/秒。
任何想法如何改進這個?
事實證明,如果您想每秒發送超過幾百條消息,PublishEventAsync 調用確實是一個瓶頸。
但事實證明,Dapr 團隊已經在開發批量發布 API https://github.com/dapr/docs/blob/12bbac91d47c5753e34e9dd84bda9dabeae02e66/daprdocs/content/en/reference/api/pubsub_api.md#publish-multiple -messages-to-a-given-topic這提供了更好的性能。
我能夠將它增加到 9000 條消息/秒,批處理大小為 100(在快速的 Azure-VM 上,本地它只能像 confluent 庫一樣增加到 ~1000 m/sec)
這也是我從 Shubham Sharma 獲得的有用示例https://github.com/shubham1172/sample-dapr-bulk-publish
如果你想使用新的 API,現在你需要從主分支編譯你自己的版本。 編譯后,您需要用新版本替換 .dapr 目錄中的 daprd(.exe)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.