【问题标题】:Gatling scenario with 10 requests per hour (less that 1 rps)Gatling 场景,每小时 10 个请求(少于 1 rps)
【发布时间】:2017-03-17 04:10:49
【问题描述】:

我需要编写模拟真实用户交互的 Gatling 场景。它应该偶尔发出一些请求,例如每个用户每小时 10 个(总共 20 个用户)。

根据我在文档中看到的内容,constantUsersPerSec 接受双精度,但它是四舍五入的,而 reachRps 在限制中仅处理秒数。所以,不能低于 1 rps。

是否可以使用 Gatling 编写这样的场景?

【问题讨论】:

    标签: scala gatling


    【解决方案1】:

    所以你的场景看起来像“2 小时,每 6 分钟发送一次请求”或“在 2 小时内以每小时 10 个用户的恒定速率......”。

    选项 1

    constantUsersPerSec 在内部舍入为 int 乘以持续时间的秒数。所以应该根据速率选择持续时间,使结果大于1。

    在你的情况下,

    def perHour(rate : Double): Double = rate / 3600
    
    constantUsersPerSec(perHour(10)) during(2 hours)
    

    这会导致

    10/3600 个用户 * (2 * 60 * 60) 秒 = 20 个用户

    选项 2

    通过注入步骤

    setUp(
      scn.inject(
        atOnceUsers(1),
        nothingFor(6 minutes),
        atOnceUsers(1),
        nothingFor(6 minutes),
        //... and so forth...
      )
    )
    

    或在第二种方法中生成注入步骤

    def injections(): List[InjectionStep] = List(...)
    
    setUp(scn.inject(injections : _*))
    

    【讨论】:

    • 我使用 Gatling 2.2.0,它确实接受低于 1 的值,我根据每分钟规格定义我的负载,即每分钟 5 个用户,这意味着每秒 0.4167 个用户,并且工作中。 Gatling 不接受的是带有 0 的 rampUsersPerSec
    • 另外一件事,Gatling 中似乎存在一个错误,至少高达 2.2.3 (github.com/gatling/gatling/issues/3205),将负载分布在 0-1 用户/秒之间,四舍五入到秒,所以只有分数有用户之间的整数秒正常工作,其他人要么变平要么压缩。 IE。 0.5、0.4、0.3、0.25、0.2 等效果很好,0.6 不行
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-06
    相关资源
    最近更新 更多