MassTransit and MaxConcurrentCalls not behaving as expected?

旧城冷巷雨未停 提交于 2019-12-13 07:28:17

问题


I'm using MassTransit as my messaging framework, running on top of Azure Service Bus. I'm running MassTransit from inside a WebJob (although I don't think that matters)

Now I'm trying to get MassTransit to process multiple messages at the same time, as I'm now dealing with messages that individually take a while to process. So to speed up performance, I don't want each message to be processed one by one.

I tried setting MaxConcurrentCalls to , for example, 30, but that doesn't seem to do it. Messages are still picked up by my consumer one by one.

I also tried setting the PrefetchCount to 5 etc, but it doesn't change anything.

What am I doing wrong? Any help is greatly appreciated


回答1:


So, I did some testing using MassTransit-Benchmark, and I'm able to get many concurrent consumers executing with Azure Service Bus using MassTransit 3.4.1.

With that in mind, realize that Azure is not fast, so if your consumer is doing nearly nothing (and completes in less than a few ms), it's unlikely that you'll see more than one at a time due to how poorly message delivery is with service bus. I had to add a delay of 3ms to the consumer to get up to 70-80 concurrent consumers. Without the delay, it was sitting around 2-3 concurrent consumers.

So, consider adjusting some settings. Also, there is a batch timeout you can set on the host that will help if you reduce it to under 10ms, even 5ms, if you are doing may small messages. A higher prefetch count helps as well.



来源:https://stackoverflow.com/questions/39782983/masstransit-and-maxconcurrentcalls-not-behaving-as-expected

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!