我们可以在负载测试期间增加 JMeter 中的线程数吗?没有预定的增量..!

Can we increase Thread count in JMeter during load test ? not scheduled increment..!

我们可以在负载测试期间增加 JMeter 中的线程数吗? 我正在使用 Jmeter3.2 版本,如何配置它或在负载测试期间增加线程数

您可以使用变量/属性参数化线程计数。但是,一旦测试开始,比如有 5 个线程,当测试为 运行 时,您不能将其更改为 10 个线程。

你不能增加线程的数量(如 Vins 所说),但你可以启动 maximum 个你需要的线程,并让大多数线程空闲直到测试告诉他们做某事。

例如:假设您想从 5 个线程开始,当 myVar 变为 true:

时将线程增加到 10 个
Thread Group 
 Number of threads: 10

    While Controller 
     Condition: ${__javaScript(${__threadNum} > 5 && '${myVar}' != 'true')}

       Constant Timer <-- thread will idle here for a bit and check condition again

    Samplers <-- when not idling, script starts here

因此 5 个以上的线程将在 While Controller 下空闲,定期检查条件(周期由 Constant Timer 决定)。当条件不再满足时,他们将退出 While 并继续执行脚本。

当然这只是一个方法,您可以根据自己的需要进行调整(例如条件可以简单也可以复杂,可以通过多次修改变量来动态启用和禁用线程等)。

您可以使用插件Ultimate thread group。您必须在 运行 测试之前进行设置。很遗憾,您将无法在测试期间手动添加线程。

您无法操纵线程数(虚拟用户),但是您可以实时控制每分钟的请求数(又名吞吐量),这应该是一个可行的替代方案。

  1. Constant Throughput Timer 添加到您的线程组
  2. 将所需的初始吞吐量定义为 JMeter 属性 using __P() function like ${__P(throughput,)}:

  3. 就是这样,现在您可以通过修改 throughput 属性 来控制执行请求的频率,例如使用 __setProperty() function. Moreover, you can even do this outside of JMeter via for example Beanshell Server