Beispiel #1
0
        public void IterationSetup()
        {
            QueueName    = "CookedRabbit.Benchmark.Scaling";
            ExchangeName = string.Empty;

            // Configured for performance.
            var seasoning = new RabbitSeasoning
            {
                ThrottleFastBodyLoops = false,
                ThrowExceptions       = false,
                WriteErrorsToConsole  = false,
                WriteErrorsToILogger  = false,
                BatchBreakOnException = true
            };

            seasoning.PoolSettings.EnableAutoScaling         = true;
            seasoning.PoolSettings.EmptyPoolWaitTime         = 10;
            seasoning.PoolSettings.WriteSleepNoticeToConsole = false;
            seasoning.PoolSettings.ConnectionPoolCount       = 4;
            seasoning.PoolSettings.ChannelPoolCount          = 16;

            var channelPool = Factories.CreateRabbitChannelPoolAsync(seasoning).GetAwaiter().GetResult();

            _deliveryService    = new RabbitDeliveryService(seasoning, channelPool);
            _topologyService    = new RabbitTopologyService(seasoning, channelPool);
            _maintenanceService = new RabbitMaintenanceService(seasoning, channelPool);

            _topologyService.QueueDeclareAsync(QueueName).GetAwaiter().GetResult();
            _maintenanceService.PurgeQueueAsync(QueueName).GetAwaiter().GetResult();

            Payloads = CreatePayloadsAsync(MessagesToSend, MessageSizes).GetAwaiter().GetResult();
        }
Beispiel #2
0
        public async Task Benchmark_Delivery_PublishManyAsync(int messagesToSend, int messageSizes)
        {
            if (FirstRun)
            {
                await Setup(messagesToSend, messageSizes);
            }

            var success = await _deliveryService.PublishManyAsync(ExchangeName, QueueName, Payloads, false, null);

            await _maintenanceService.PurgeQueueAsync(QueueName);
        }
Beispiel #3
0
        public async Task PublishInParallelAsync()
        {
            QueueName = "CookedRabbit.Benchmark";

            // Configured for performance.
            var seasoning = new RabbitSeasoning
            {
                ThrottleFastBodyLoops = false,
                ThrowExceptions       = false,
                WriteErrorsToConsole  = false,
                WriteErrorsToILogger  = false,
                BatchBreakOnException = true
            };

            seasoning.PoolSettings.EnableAutoScaling         = true;
            seasoning.PoolSettings.EmptyPoolWaitTime         = 0;
            seasoning.PoolSettings.WriteSleepNoticeToConsole = false;
            seasoning.PoolSettings.ConnectionPoolCount       = 8;
            seasoning.PoolSettings.ChannelPoolCount          = 32;

            var channelPool = await Factories.CreateRabbitChannelPoolAsync(seasoning).ConfigureAwait(false);

            _deliveryService    = new RabbitDeliveryService(seasoning, channelPool);
            _topologyService    = new RabbitTopologyService(seasoning, channelPool);
            _maintenanceService = new RabbitMaintenanceService(seasoning, channelPool);

            var queueNames = new List <string>
            {
                $"{QueueName}.Scaling_00",
                $"{QueueName}.Scaling_01",
                $"{QueueName}.Scaling_02",
                $"{QueueName}.Scaling_03",
                $"{QueueName}.Scaling_04",
                $"{QueueName}.Scaling_05",
                $"{QueueName}.Scaling_06",
                $"{QueueName}.Scaling_07",
                $"{QueueName}.Scaling_08",
                $"{QueueName}.Scaling_09",
            };

            var envelopes = await CreateEnvelopesAsync(queueNames, MessagesToSend, MessageSizes).ConfigureAwait(false);

            foreach (string queueName in queueNames)
            {
                await _topologyService.QueueDeclareAsync(queueName).ConfigureAwait(false);

                await _maintenanceService.PurgeQueueAsync(queueName).ConfigureAwait(false);
            }

            await _deliveryService.PublishInParallelAsync(envelopes).ConfigureAwait(false);
        }
        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    // Cleanup
                    try
                    {
                        MaintenanceService.PurgeQueueAsync(QueueName).GetAwaiter().GetResult();
                    }
                    catch { }

                    TopologyService.Dispose();
                    DeliveryService.Dispose();
                    MaintenanceService.Dispose();
                }

                disposedValue = true;
            }
        }
Beispiel #5
0
 public void IterationCleanup()
 {
     _maintenanceService.PurgeQueueAsync(QueueName).GetAwaiter().GetResult();
 }
Beispiel #6
0
        public static async Task PublishInParallelAsync()
        {
            // Configured for performance.
            var seasoning = new RabbitSeasoning
            {
                ThrottleFastBodyLoops = false,
                ThrowExceptions       = false,
                WriteErrorsToConsole  = false,
                WriteErrorsToILogger  = false,
                BatchBreakOnException = true
            };

            seasoning.PoolSettings.EnableAutoScaling         = true;
            seasoning.PoolSettings.EmptyPoolWaitTime         = 0;
            seasoning.PoolSettings.WriteSleepNoticeToConsole = false;
            seasoning.PoolSettings.ConnectionPoolCount       = 10;
            seasoning.PoolSettings.ChannelPoolCount          = 40;

            await Console.Out.WriteLineAsync($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}: Creating RabbitChannelPool and RabbitServices...").ConfigureAwait(false);

            var sw = Stopwatch.StartNew();

            var channelPool = await Factories.CreateRabbitChannelPoolAsync(seasoning).ConfigureAwait(false);

            var deliveryService    = new RabbitDeliveryService(seasoning, channelPool);
            var topologyService    = new RabbitTopologyService(seasoning, channelPool);
            var maintenanceService = new RabbitMaintenanceService(seasoning, channelPool);

            sw.Stop();

            await Console.Out.WriteLineAsync($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}: Creating RabbitChannelPool and RabbitServices finished. Time: {sw.ElapsedMilliseconds} ms").ConfigureAwait(false);

            await Console.Out.WriteLineAsync($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}: Creating test data...").ConfigureAwait(false);

            sw.Reset();
            sw.Start();

            var queueNames = new List <string>
            {
                $"{QueueName}.Scaling_00",
                $"{QueueName}.Scaling_01",
                $"{QueueName}.Scaling_02",
                $"{QueueName}.Scaling_03",
                $"{QueueName}.Scaling_04",
                $"{QueueName}.Scaling_05",
                $"{QueueName}.Scaling_06",
                $"{QueueName}.Scaling_07",
                $"{QueueName}.Scaling_08",
                $"{QueueName}.Scaling_09",
            };

            var envelopes = await CreateEnvelopesAsync(queueNames, MessagesToSend, MessageSizes).ConfigureAwait(false);

            sw.Stop();

            await Console.Out.WriteLineAsync($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}: Creating test data finished. Time: {sw.ElapsedMilliseconds} ms").ConfigureAwait(false);

            await Console.Out.WriteLineAsync($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}: Creating and/or Purging benchmark queues...").ConfigureAwait(false);

            sw.Reset();
            sw.Start();
            foreach (string queueName in queueNames)
            {
                await topologyService.QueueDeclareAsync(queueName).ConfigureAwait(false);

                await maintenanceService.PurgeQueueAsync(queueName).ConfigureAwait(false);
            }
            sw.Stop();

            await Console.Out.WriteLineAsync($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}: Creating and/or Purging finished. Time: {sw.ElapsedMilliseconds} ms").ConfigureAwait(false);

            await Console.Out.WriteLineAsync($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}: Publish test starting...").ConfigureAwait(false);

            sw.Reset();
            sw.Start();
            await deliveryService.PublishInParallelAsync(envelopes).ConfigureAwait(false);

            sw.Stop();

            await Console.Out.WriteLineAsync($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}: Publish finished. Time: {sw.ElapsedMilliseconds} ms").ConfigureAwait(false);

            await Console.Out.WriteLineAsync($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}: Publish rate {(MessagesToSend/1.0 / (sw.ElapsedMilliseconds / 1000.0)).ToString("0.###")} msg/s").ConfigureAwait(false);

            await Console.Out.WriteLineAsync($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}: Purging benchmark queues...").ConfigureAwait(false);

            sw.Reset();
            sw.Start();
            foreach (string queueName in queueNames)
            {
                await topologyService.QueueDeclareAsync(queueName).ConfigureAwait(false);

                await maintenanceService.PurgeQueueAsync(queueName).ConfigureAwait(false);
            }
            sw.Stop();

            await Console.Out.WriteLineAsync($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}: Purging finished. Time: {sw.ElapsedMilliseconds} ms").ConfigureAwait(false);

            await Console.Out.WriteLineAsync($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}: Shutting down/disposing of services...").ConfigureAwait(false);

            sw.Reset();
            sw.Start();
            deliveryService.Dispose();
            topologyService.Dispose();
            maintenanceService.Dispose();
            sw.Stop();

            await Console.Out.WriteLineAsync($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}: Shutting down/disposing of services finished. Time: {sw.ElapsedMilliseconds} ms").ConfigureAwait(false);
        }