如何使用 Gatling 在封闭模型中实现持续并发活跃用户?
How to achieve constant concurrent active users in closed model using Gatling?
我的问题在某种程度上与 and 相关,但不知何故并没有真正回答我的问题。
我的测试用例非常简单,我需要在一段时间内(例如 60 秒)不断生成持续活跃的并发用户(例如 10 个并发用户)。
我的代码是这样的
val TestProtocolBuilder: HttpProtocolBuilder = http.baseUrl("https://computer-database.gatling.io")
object Test {
val test =
exec(http("Test_Only")
.get("/computers")
.check(status.in(200, 404))
)
}
val TestOnly = scenario("Test Only").exec(Test.test)
setUp(
TestOnly.inject(
constantConcurrentUsers(10) during(60 seconds)
).protocols(TestProtocolBuilder)
)
这 documentation 说
constantConcurrentUsers(nbUsers) during(duration)
: 注入使系统中的并发用户数恒定
我希望有 10 个并发活跃用户不断点击 API 60 秒。任何时候不超过10个用户也不少于10个用户。
我在 HTML 报告中看到的是,任何给定时间的活跃用户都远远高于 10(几乎翻倍)。
向 documentation 学习,它说
This chart displays the active users during the simulation : total and per scenario.
“Active users” is neither “concurrent users” or “users arrival rate”. It’s a kind of mixed metric that serves for both open and closed workload models and that represents “users who were active on the system under load at a given second”.
It’s computed as:
(number of alive users at previous second) + (number of users that were started during this second) - (number of users that were terminated during previous second)
问题:
- 为什么加特林在测试期间不断终止用户和启动新用户?有什么意义?
- 如果
constantConcurrentUsers(10) during(60 seconds)
给我更高的活跃用户数,我怎样才能在测试期间保持 10 个恒定的并发活跃用户(不多不少)一直点击我的 API并在测试期间保持波动?我需要坚持我的测试用例而不是过度加载 API.
- 在上图中,在给定时间
the number of request = 7
和 the active users = 20
。这是否意味着在给定时间,有 7 个活跃用户发出请求,并且有 20 - 7 = 13 个活跃用户闲置等待从 API 返回的响应?
谢谢。
Why Gatling keep terminating users and starting new users during the test period? What's the point?
虚拟用户的生命周期取决于您的场景。 注入 配置文件仅在 injected/started 时驱动。
如果您想让您的用户在一次请求后不终止,请在您的场景中添加一个循环。
How can I get a constant 10 concurrent active users
胡说八道。正如你自己引用的那样,并发!=活跃。我保证您有固定数量的并发用户,这意味着恰好有 10 个用户同时存活。问题是,由于您的场景只有 1 个请求,用户会立即终止并被新请求替换。
Does it mean that at that given time, there are 7 active users sending out requests and there are 20 - 7 = 13 active users sitting idle waiting for the responses to come back from the API ?
这意味着虚拟用户的生命周期在 2 秒之间重叠,因此他们在 2 个不同的第二个桶中被视为活着。
我的问题在某种程度上与
我的测试用例非常简单,我需要在一段时间内(例如 60 秒)不断生成持续活跃的并发用户(例如 10 个并发用户)。
我的代码是这样的
val TestProtocolBuilder: HttpProtocolBuilder = http.baseUrl("https://computer-database.gatling.io")
object Test {
val test =
exec(http("Test_Only")
.get("/computers")
.check(status.in(200, 404))
)
}
val TestOnly = scenario("Test Only").exec(Test.test)
setUp(
TestOnly.inject(
constantConcurrentUsers(10) during(60 seconds)
).protocols(TestProtocolBuilder)
)
这 documentation 说
constantConcurrentUsers(nbUsers) during(duration)
: 注入使系统中的并发用户数恒定
我希望有 10 个并发活跃用户不断点击 API 60 秒。任何时候不超过10个用户也不少于10个用户。
我在 HTML 报告中看到的是,任何给定时间的活跃用户都远远高于 10(几乎翻倍)。
向 documentation 学习,它说
This chart displays the active users during the simulation : total and per scenario. “Active users” is neither “concurrent users” or “users arrival rate”. It’s a kind of mixed metric that serves for both open and closed workload models and that represents “users who were active on the system under load at a given second”.
It’s computed as: (number of alive users at previous second) + (number of users that were started during this second) - (number of users that were terminated during previous second)
问题:
- 为什么加特林在测试期间不断终止用户和启动新用户?有什么意义?
- 如果
constantConcurrentUsers(10) during(60 seconds)
给我更高的活跃用户数,我怎样才能在测试期间保持 10 个恒定的并发活跃用户(不多不少)一直点击我的 API并在测试期间保持波动?我需要坚持我的测试用例而不是过度加载 API. - 在上图中,在给定时间
the number of request = 7
和the active users = 20
。这是否意味着在给定时间,有 7 个活跃用户发出请求,并且有 20 - 7 = 13 个活跃用户闲置等待从 API 返回的响应?
谢谢。
Why Gatling keep terminating users and starting new users during the test period? What's the point?
虚拟用户的生命周期取决于您的场景。 注入 配置文件仅在 injected/started 时驱动。 如果您想让您的用户在一次请求后不终止,请在您的场景中添加一个循环。
How can I get a constant 10 concurrent active users
胡说八道。正如你自己引用的那样,并发!=活跃。我保证您有固定数量的并发用户,这意味着恰好有 10 个用户同时存活。问题是,由于您的场景只有 1 个请求,用户会立即终止并被新请求替换。
Does it mean that at that given time, there are 7 active users sending out requests and there are 20 - 7 = 13 active users sitting idle waiting for the responses to come back from the API ?
这意味着虚拟用户的生命周期在 2 秒之间重叠,因此他们在 2 个不同的第二个桶中被视为活着。