private async Task RunAsync(Parameters parameters)
        {
            var secrets = SecretConfiguration.Load(parameters.SecretSource);
            var channel = await Channels.CreateSendChannel(parameters.ClusterId, secrets);

            _logger.LogInformation($"Waiting {parameters.Wait} seconds before starting...");
            await Task.Delay(TimeSpan.FromSeconds(parameters.Wait));

            for (var i = 0; i < parameters.Rounds; i++)
            {
                _logger.LogInformation($"Round #{i + 1}: sending {parameters.ServersPerRound} orders [Restart: {parameters.Restart}, Graceful: {parameters.Graceful}]");
                var responses = await channel.SendMessages(
                    GetMessages(),
                    new CancellationTokenSource(TimeSpan.FromSeconds(parameters.RoundDelay)).Token);

                _logger.LogInformation($"Round #{i + 1}: silos {string.Join(",", responses.Select(r => r.ServerName))} acked");
                _logger.LogInformation($"Round #{i + 1}: waiting {parameters.RoundDelay}");
                await Task.Delay(TimeSpan.FromSeconds(parameters.RoundDelay));
            }

            List <ServerMessage> GetMessages()
            {
                var msgs = new List <ServerMessage>();

                for (var i = 0; i < parameters.ServersPerRound; i++)
                {
                    msgs.Add(new ServerMessage(parameters.Graceful, parameters.Restart));
                }
                return(msgs);
            }
        }
Exemple #2
0
        public async Task Run(ClientParameters clientParams, LoadGeneratorParameters loadParams)
        {
            var secrets     = SecretConfiguration.Load(clientParams.SecretSource);
            var hostBuilder = new HostBuilder().UseOrleansClient((ctx, builder) =>
                                                                 builder.Configure <ClusterOptions>(options => { options.ClusterId = clientParams.ClusterId; options.ServiceId = clientParams.ServiceId; })
                                                                 .Configure <ConnectionOptions>(options => clientParams.ConnectionsPerEndpoint = 2)
                                                                 .UseAzureStorageClustering(options => options.ConfigureTableServiceClient(secrets.ClusteringConnectionString)));

            using var host = hostBuilder.Build();

            _logger.LogInformation("Connecting to cluster...");
            await host.StartAsync();

            var client = host.Services.GetService <IClusterClient>();

            var generator = new ConcurrentLoadGenerator <T>(
                numWorkers: loadParams.NumWorkers,
                blocksPerWorker: loadParams.BlocksPerWorker != 0 ? loadParams.BlocksPerWorker : int.MaxValue,
                requestsPerBlock: loadParams.RequestsPerBlock,
                issueRequest: _scenario.IssueRequest,
                getStateForWorker: workerId => _scenario.GetStateForWorker(client, workerId),
                logger: _logger,
                logIntermediateResults: true);

            _logger.LogInformation("Warming-up...");
            await generator.Warmup();

            var cts = loadParams.Duration != 0
                ? new CancellationTokenSource(TimeSpan.FromSeconds(loadParams.Duration))
                : new CancellationTokenSource();

            _logger.LogInformation("Running");
            var report = await generator.Run(cts.Token);

            // Register the measurements. n0 -> format as natural number
            BenchmarksEventSource.Register("requests", Operations.First, Operations.Sum, "Requests", "Number of requests completed", "n0");
            BenchmarksEventSource.Register("failures", Operations.First, Operations.Sum, "Failures", "Number of failures", "n0");
            BenchmarksEventSource.Register("rps", Operations.First, Operations.Sum, "Rate per second", "Rate per seconds", "n0");

            // Register the measurement values
            BenchmarksEventSource.Measure("requests", report.Completed);
            BenchmarksEventSource.Measure("failures", report.Failures);
            BenchmarksEventSource.Measure("rps", report.RatePerSecond);

            await host.StopAsync();
        }
Exemple #3
0
        private async Task RunAsync(Parameters parameters)
        {
            _logger.LogInformation("Connecting to cluster...");
            var secrets     = SecretConfiguration.Load(parameters.SecretSource);
            var hostBuilder = new HostBuilder()
                              .UseOrleansClient(builder => {
                builder
                .Configure <ClusterOptions>(options => { options.ClusterId = parameters.ClusterId; options.ServiceId = parameters.ServiceId; })
                .UseAzureStorageClustering(options => options.ConfigureTableServiceClient(secrets.ClusteringConnectionString));
            });

            using var host = hostBuilder.Build();
            await host.StartAsync();

            var client = host.Services.GetService <IClusterClient>();

            var counterGrain = client.GetGrain <ICounterGrain>(parameters.CounterKey);

            var duration = await counterGrain.GetRunDuration();

            BenchmarksEventSource.Register("duration", Operations.First, Operations.Last, "duration", "duration", "n0");
            BenchmarksEventSource.Measure("duration", duration.TotalSeconds);

            var initialWait = await counterGrain.WaitTimeForReport();

            _logger.LogInformation($"Counters should be ready in {initialWait}");
            await Task.Delay(initialWait);

            _logger.LogInformation($"Counters ready");
            foreach (var counter in parameters.Counters)
            {
                var value = await counterGrain.GetTotalCounterValue(counter);

                _logger.LogInformation($"{counter}: {value}");
                BenchmarksEventSource.Register(counter, Operations.First, Operations.Sum, counter, counter, "n0");
                BenchmarksEventSource.Measure(counter, value);
                if (string.Equals(counter, "requests", StringComparison.InvariantCultureIgnoreCase))
                {
                    var rps = (float)value / duration.TotalSeconds;
                    BenchmarksEventSource.Register("rps", Operations.First, Operations.Last, "rps", "Requests per second", "n0");
                    BenchmarksEventSource.Measure("rps", rps);
                }
            }

            await host.StopAsync();
        }