公交使用RabbitMQ的性能很慢吗? [英] Masstransit use RabbitMQ is very slow performance?

查看:66
本文介绍了公交使用RabbitMQ的性能很慢吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在不使用Masstransit的情况下使用RabbitMQ,并在100秒内每秒发送10,000条消息和100万条消息.

但是在将Masstransit与RabbitMQ结合使用后,我的机器上的性能非常低.

当发布/使用消息时,硬盘非常活跃(99%的使用率),并且此过程的CPU活动几乎为0%.

使用以下代码运行发布者/订阅者控制台应用程序时:

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

在6秒钟内发布了100条消息,我不知道为什么它很慢.


我的机器的配置和软件版本为:

Windows 8.1 64位

Intel Core i3 3.30GHz

内存8GB


Visual Studio 2013 C#.Net 4.5.1

Erlang 6.3

RabbitMQ 3.4.4

大众运输2.9.9

RabbitMQ.Client 3.4.0

解决方案

这是因为在幕后,MassTransit正在等待RabbitMQ对消息进行 Ack 确认,以确保该消息已被代理成功接受然后再返回给呼叫者.没有此等待,如果代理无法接收到写入,则消息可能会丢失.

使用MassTransit v3(当前处于预发行版本), Publish 方法(以及所有 Send 方法)现在异步,返回 Task 可以等待(或者,如果您不关心结果,则可以等待).

我可以为.NET 4.0开发人员在版本2.9.9中添加 PublishAsync 方法,实际上,对于那些仍在使用当前稳定版本的应用程序,这可能是我的临时解决方法.将 NoWait 选项添加到 SendContext 可能也很有用,从而允许应用程序选择退出 Ack 等待行为.

老实说,在用例中,我只喜欢耐久性而不是性能.

I used RabbitMQ without Masstransit and send 10,000 message/per sec and One million message in 100 second.

But after using Masstransit with RabbitMQ the performance is very low in my machine.

The hard disk is very active (99% usage) when publish/consume message and CPU activity for this process is almost 0%.

When the run Publisher/Subscriber console application with this code :

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.


My machine's configuration and software version is:

Windows 8.1 64bit

Intel Core i3 3.30GHz

Memory 8GB


Visual Studio 2013 C#.Net 4.5.1

Erlang 6.3

RabbitMQ 3.4.4

Masstransit 2.9.9

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. 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).

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. It may also be useful to add a NoWait option to the SendContext, allowing the application to opt-out of the Ack wait behavior.

I just favor durability over performance in my use case, honestly.

这篇关于公交使用RabbitMQ的性能很慢吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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