Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

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

like image 506
Mohammad Radman Far Avatar asked Apr 20 '15 12:04

Mohammad Radman Far


1 Answers

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.

like image 149
Chris Patterson Avatar answered Sep 21 '22 13:09

Chris Patterson