MassTransit和MaxConcurrentCalls行为不符合预期吗? [英] MassTransit and MaxConcurrentCalls not behaving as expected?

查看:122
本文介绍了MassTransit和MaxConcurrentCalls行为不符合预期吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将MassTransit用作消息传递框架,并在Azure Service Bus上运行.我正在WebJob内部运行MassTransit(尽管我认为这并不重要)

现在,我正试图让MassTransit同时处理多条消息,因为我现在正在处理需要花费一段时间才能处理的消息.因此,为了提高性能,我不希望每条消息都一个接一个地处理.

我尝试将MaxConcurrentCalls设置为,例如30,但这似乎没有实现.消费者仍然可以一一接听邮件.

我还尝试将PrefetchCount设置为5等,但它没有任何改变.

我做错了什么?任何帮助将不胜感激

解决方案

因此,我使用MassTransit-Benchmark进行了一些测试,并且能够使许多并发使用者使用MassTransit 3.4.1与Azure Service Bus执行. /p>

请牢记这一点,请认识到Azure的运行速度并不快,因此,如果您的消费者几乎什么都不做(并且在不到几毫秒的时间内完成),由于操作方式的不同,您一次看到的对象不大可能不止一次服务总线无法很好地传递消息.我必须给使用者增加3ms的延迟,以使70-80个并发使用者同时使用.毫不拖延,它大约有2-3个并发消费者.

因此,请考虑调整某些设置.此外,您可以在主机上设置一个批处理超时,如果将其减少到10毫秒以下,甚至5毫秒以下(如果您这样做的话),这可能会有所帮助,这可能会产生一些小消息.较高的预取次数也有帮助.

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

解决方案

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.

这篇关于MassTransit和MaxConcurrentCalls行为不符合预期吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆