【问题标题】:Gatling doesn't send specified number of requests per secondsGatling 每秒不发送指定数量的请求
【发布时间】:2019-05-02 08:30:33
【问题描述】:

我正在使用以下 gatling3 代码测试我的 API

setUp(scn.inject(constantUsersPerSec(300) during (10 minutes))).throttle(
reachRps(300) in (10 seconds),
holdFor(5 minutes),
reachRps(500) in (10 seconds),
holdFor(5 minutes)
).protocols(httpProtocol)

我期望在前 5 分钟内,gatling 每秒发送 300 个请求,在接下来的 5 分钟内,gatling 每秒发送 500 个请求。但是测试报告显示,gatling 在这 10 分钟内每秒发送 300 个请求。

为什么会这样?

【问题讨论】:

  • 每个用户都发送 1 个请求吗? Throttle 会限制最大发送请求,但不能保证最小,因此如果这 300 个恒定用户/秒仅发送 300 个请求/秒,那么每秒不可能达到 500 个请求。

标签: performance gatling


【解决方案1】:

你想要做的是类似这样的事情:

setUp(scn.inject(constantUsersPerSec(500) during (10 minutes))).throttle(
reachRps(300) in (10 seconds),
holdFor(5 minutes),
reachRps(500) in (10 seconds),
holdFor(5 minutes)
).protocols(httpProtocol)

油门将是您测试的上限,因此如果您将每秒用户数固定为 500,但将其限制为 300,它将保持限制为 300,但是一旦您将油门增加到 500,您应该看到 rps 上升到该阈值,因为 constantUsersPerSec(500) 为您提供了足够的流量以使您达到该点。

【讨论】:

    【解决方案2】:

    我认为您图表中显示的时间段是测试的初始时间段,从 ~12:31 到 12:21 达到 300 rps。之后,加特林机将保持 5 分钟,然后再以 10 秒的时间完成 500 rps。你等了 10 秒 + 5 分钟 + 10 秒 + 5 分钟?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-12
      • 1970-01-01
      • 2020-09-12
      • 1970-01-01
      • 2015-04-22
      • 1970-01-01
      相关资源
      最近更新 更多