public async Task PublishMessagesToLocalHostAsync(int messagesToSend, List <byte[]> payloads) { var queueName1 = "CookedRabbit.Benchmark.Scaling1"; var queueName2 = "CookedRabbit.Benchmark.Scaling2"; var queueName3 = "CookedRabbit.Benchmark.Scaling3"; var queueName4 = "CookedRabbit.Benchmark.Scaling4"; var queueName5 = "CookedRabbit.Benchmark.Scaling5"; var exchangeName = string.Empty; var createSuccess1 = await _topologyService.QueueDeclareAsync(queueName1); var createSuccess2 = await _topologyService.QueueDeclareAsync(queueName2); var createSuccess3 = await _topologyService.QueueDeclareAsync(queueName3); var createSuccess4 = await _topologyService.QueueDeclareAsync(queueName4); var createSuccess5 = await _topologyService.QueueDeclareAsync(queueName5); var task1 = _deliveryService.PublishManyAsync(exchangeName, queueName1, payloads, false, null); var task2 = _deliveryService.PublishManyAsync(exchangeName, queueName2, payloads, false, null); var task3 = _deliveryService.PublishManyAsync(exchangeName, queueName3, payloads, false, null); var task4 = _deliveryService.PublishManyAsync(exchangeName, queueName4, payloads, false, null); var task5 = _deliveryService.PublishManyAsync(exchangeName, queueName5, payloads, false, null); await Task.WhenAll(new Task[] { task1, task2, task3, task4, task5 }); }
public BenchmarkFixture() { 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 = 4; var channelPool = new RabbitChannelPool(); channelPool.Initialize(seasoning).GetAwaiter().GetResult(); DeliveryService = new RabbitDeliveryService(seasoning, channelPool); TopologyService = new RabbitTopologyService(seasoning, channelPool); MaintenanceService = new RabbitMaintenanceService(seasoning, channelPool); TopologyService.QueueDeclareAsync(QueueName).GetAwaiter().GetResult(); Payloads = CreatePayloadsAsync(MessagesToSend, MessageSize).GetAwaiter().GetResult(); }
private async Task Setup(int messagesToSend, int messageSizes) { 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 = new RabbitChannelPool(); await channelPool.Initialize(seasoning); _deliveryService = new RabbitDeliveryService(seasoning, channelPool); _topologyService = new RabbitTopologyService(seasoning, channelPool); _maintenanceService = new RabbitMaintenanceService(seasoning, channelPool); await _topologyService.QueueDeclareAsync(QueueName); Payloads = await CreatePayloadsAsync(messagesToSend, messageSizes); FirstRun = false; }
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); }
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); }