我正在尝试在我们的一台服务器上对 Kafka 实例进行负载测试。 这是使用 NBomber 执行此操作的代码:
public static void Run()
{
var testScenario = NBomber.CSharp.Step.Create("testScenario",
async context =>
{
try
{
// The testData is a string variable that reads contents from a text file in the Init method.
var kafkaObject = new KafkaObject { Topic = TestTopic, Message =testData };
SampleKafkaFlow sampleKafkaFlow = new SampleKafkaFlow();
var response = await sampleKafkaFlow.SendMessageToKafka(kafkaObject);
return Response.Ok();
}
catch (Exception ex)
{
return Response.Fail(ex.Message);
}
});
var scenario = ScenarioBuilder.CreateScenario("scenario", testScenario)
.WithoutWarmUp()
.WithInit(Init)
.WithLoadSimulations(new[]
{
Simulation.InjectPerSec(rate: 100, during: TimeSpan.FromMinutes(3))
});
NBomber.CSharp.NBomberRunner
.RegisterScenarios(scenario)
.WithReportFileName($"testScenario-Report-{DateTime.UtcNow.ToString("yyyy-dd-M--HH-mm-ss")}")
.WithReportFolder("test_reports")
.WithReportFormats(ReportFormat.Html)
.Run();
}
我的笔记本电脑配置:
第 10 代 Core i5,配备 16 Gb RAM,运行 Windows 10。
运行负载测试时,仅 VS 2022 正在运行。
现在我假设在 100 RPS 下,在 3 分钟的执行时间内总共会生成 18k 个请求。报告说的不同 - 虽然它总共运行了 3 分钟,但总共只有 2057 个请求!
我在这里缺少什么?
如何使用更高的 RPS 进行负载测试?
提前致谢。
可能NBomber本身有问题https://github.com/PragmaticFlow/NBomber/issues/488
还要检查 nbomber 日志 – 它可能包含很多
Error: step unhandled exception: One or more errors occurred. (Too many open files in system
或其他表明操作系统限制您的负载测试的错误