EasyNetQ: Slow EasyNetQ vs RabbitMq performance for Tasks.

I created two the same simple programs, where count = 500:

In first case I’ve used RabbitMQ.Client.dll, 3.6.0.0

private static void TestManyTasksMq(int count)
        {
            ConnectionFactory connectionFactory = new ConnectionFactory();
            connectionFactory.Uri = "amqp://admin:1@localhost:5672";
            IConnection connection = connectionFactory.CreateConnection();

            var stopwatch = new Stopwatch();
            stopwatch.Start();
            var tasks = Enumerable.Range(1, count).Select(i =>
            {
                return Task.Factory.StartNew(() =>
                {
                    var channel = connection.CreateModel();
                    var arguments = new Dictionary<string, object> { { "x-expires", 60000 } };                    
                    var queueName = string.Format("test.{0}", Guid.NewGuid());
                    channel.QueueDeclare(queueName, false, true, true, arguments);
                    channel.QueueBind(queueName, "test.exchange", "test.new.*");                   
                });
            }).ToArray();

            Task.WaitAll(tasks);

            stopwatch.Stop();
            var s = stopwatch.Elapsed;

            Console.WriteLine("Time of MQ: {0:hh\\:mm\\:ss\\:fff}", s);
        }

In second case I’ve used EasyNetQ.dll, 0.63.5.454

private static void TestManyTasksEasyNetQ(int count)
       {
           using (var bus = RabbitHutch.CreateBus("host=localhost:5672;username=admin;password=1"))
           {
               var stopwatch = new Stopwatch();
               stopwatch.Start();

               IExchange exchange = bus.Advanced.ExchangeDeclare("test.exchange", ExchangeType.Topic);
               IAdvancedBus advancedBus = bus.Advanced;

               var tasks = Enumerable.Range(1, count).Select(i =>
               {
                   return Task.Factory.StartNew(() =>
                   {
                       var queueName = string.Format("test.{0}", Guid.NewGuid());
                       IQueue queue = advancedBus.QueueDeclare(queueName, false, true, true, expires: 60000);
                       advancedBus.Bind(exchange, queue, "test.new.*");                        
                   });
               }).ToArray();

               try
               {
                   Task.WaitAll(tasks);
               }
               catch (Exception ex)
               {
                   Console.WriteLine(ex.Message);
               }                

               stopwatch.Stop();
               var s = stopwatch.Elapsed;
               Console.WriteLine("Time of EasyNETQ: {0:hh\\:mm\\:ss\\:fff}", s);
           }
       }

Average results: 1: 10 seconds 2: 57 seconds

Why EasyNetQ has such slow performance? May be I do something wrong?

Thanks in advance.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 42 (25 by maintainers)

Most upvoted comments

Ok. I’ve create #666 issue.

the number of iterations 5000 “EasyNetQ” version=“1.0.1.475” targetFramework=“net451” Time of EasyNetQ: 00:00:19:721, and MAX iteration 00:00:12:332

So we get approximately the same result as for version=“0.63.6.463”. But it’s slower than MQ result: in two times (19 / 9 = 2) for all the time and in four times (12 / 3 = 4) for max iteration time. It’s not so good in my case.

@micdenny I will try to run some tests too. It would be very sad if I broke perfomance 😦 Sorry, I didn’t check new code for perfomance. I did tests under load but I checked just for correctness.