简体   繁体   English

Masstransit使用RabbitMQ是非常慢的性能?

[英]Masstransit use RabbitMQ is very slow performance?

I used RabbitMQ without Masstransit and send 10,000 message/per sec and One million message in 100 second. 我使用没有Masstransit的RabbitMQ,每秒发送10,000条消息,100秒内发送一百万条消息。

But after using Masstransit with RabbitMQ the performance is very low in my machine. 但在使用Masstransit与RabbitMQ后,我的机器性能非常低。

The hard disk is very active (99% usage) when publish/consume message and CPU activity for this process is almost 0%. 发布/使用消息时,硬盘非常活跃(使用率为99%),此过程的CPU活动几乎为0%。

When the run Publisher/Subscriber console application with this code : 使用此代码运行Publisher / Subscriber控制台应用程序时:

var bus = ServiceBusFactory.New(x =>
{
    x.UseRabbitMq();
    x.ReceiveFrom("rabbitmq://localhost/Example_Hello");
});
var message = new MyMessage() { Text = "hello", When = DateTime.Now };
for (int i = 0; i < 100; i++)
{
    bus.Publish<MyMessage>(message, x => { });
}

Published 100 message in 6 second and I don't know why is very slow. 在6秒内发布了100条消息,我不知道为什么会很慢。


My machine's configuration and software version is: 我的机器的配置和软件版本是:

Windows 8.1 64bit Windows 8.1 64位

Intel Core i3 3.30GHz 英特尔酷睿i3 3.30GHz

Memory 8GB 内存8GB


Visual Studio 2013 C#.Net 4.5.1 Visual Studio 2013 C#.Net 4.5.1

Erlang 6.3 Erlang 6.3

RabbitMQ 3.4.4 RabbitMQ 3.4.4

Masstransit 2.9.9 Masstransit 2.9.9

RabbitMQ.Client 3.4.0 RabbitMQ.Client 3.4.0

This is because under the covers, MassTransit is waiting for RabbitMQ to Ack the message, ensuring that it was successfully accepted by the broker before returning to the caller. 这是因为在封面下,MassTransit正在等待RabbitMQ Ack消息,确保它在返回调用者之前被代理成功接受。 Without this wait, if the broker fails to receive the write, the message could be lost. 如果没有这种等待,如果代理无法接收写入,则消息可能会丢失。

With MassTransit v3 (currently in pre-release), the Publish method (and all Send methods) are now async, returning a Task that can be awaited (or not, if you don't care about the outcome). 使用MassTransit v3(当前处于预发布状态), Publish方法(以及所有Send方法)现在都是异步的,返回可以等待的Task (如果您不关心结果,则返回)。

I could add a PublishAsync method for .NET 4.0 developers to version 2.9.9, in fact, that's what I may end up doing as a temporary workaround for applications still using the current stable version. 我可以为.NET 4.0开发人员添加一个PublishAsync方法到版本2.9.9,事实上,这就是我最终可能作为仍然使用当前稳定版本的应用程序的临时解决方法。 It may also be useful to add a NoWait option to the SendContext , allowing the application to opt-out of the Ack wait behavior. 这也可能是添加一个有用的NoWait选项将SendContext ,允许应用程序选择退出的Ack等待行为。

I just favor durability over performance in my use case, honestly. 老实说,我只是喜欢耐用性而不是性能。

I have found a bug in MT2 <= 2.10.1 that prevents it from correctly handling the WaitForAck flag. 我在MT2 <= 2.10.1中发现了一个错误,阻止它正确处理WaitForAck标志。 I posted a patch proposal and hope Chris releases 2.10.2 as soon as possible. 我发布了补丁提案,希望Chris尽快发布2.10.2。

The detailed information on the issue is described here: 有关该问题的详细信息,请参见此处:

https://groups.google.com/forum/#!topic/masstransit-discuss/XiqSDnJzd8U https://groups.google.com/forum/#!topic/masstransit-discuss/XiqSDnJzd8U

In short, the issue is caused by the bug in the SendContext copy constructor, despite the original context has the wait for ack flag set to false , the context that is used in the call has the flag always set to true . 简而言之,问题是由SendContext复制构造函数中的错误引起的,尽管原始上下文将等待ack标志设置为false ,但调用中使用的上下文始终将标志设置为true

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM