且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

JMeter-在多个线程组之间共享请求之间的延迟

更新时间:2021-12-04 22:43:03

鉴于您在当前输出上方提供的JMeter设置看起来正确.

Given the settings for JMeter that you have provided above your current output looks correct.

也许这里的困惑是围绕加速周期和恒定定时器的确切工作,因为在这种情况下,这些应该是影响执行顺序的唯一因素.

Perhaps the confusion here is around the exact workings of the ramp-up period and the Constant Timer as in this case these should be the only things effecting the order of execution.

Apache JMeter网站实际上将加速阶段的工作放在***状态:

The Apache JMeter site actually puts the workings of the ramp-up period best:

加速期告诉JMeter将加速"到所选线程总数需要多长时间.如果使用了10个线程,并且启动周期为100秒,那么JMeter将花费100秒来启动和运行所有10个线程.每个线程将在上一个线程开始后10(100/10)秒开始.如果有30个线程,启动周期为120秒,则每个连续线程将延迟4秒. ( https://jmeter.apache.org/usermanual/test_plan.html )>

此外,常量计时器为您提供了一种在测试计划中分隔各个步骤的方法.重要的是,这仅在每个线程内.

In addition, a Constant Timer provides a way for you to space out individual steps in your test plan. Importantly this is only inside each thread.

如此有效,您有一个加速期,这意味着一个新线程大约每秒钟启动一次.在每个线程内,每个请求都会延迟5秒.这给了我们大致如下的输出:

So effectively, you have a ramp up period that means a new thread is starting roughly every second. Inside each thread each request is delayed by 5 seconds each. This gives us an output roughly along the lines of:

  1. (开始)线程1开始-请求1执行(暂停5秒钟)
  2. (1秒)线程2启动-请求1执行(暂停5秒)
  3. (2秒)线程3启动-请求1执行(暂停5秒)
  4. (3秒)线程4启动-请求1执行(暂停5秒)
  5. (4秒)线程5启动-请求1执行(暂停5秒)
  6. (5秒)线程6启动-请求1执行(暂停5秒钟)+线程1执行请求2.

您可以看到,直到很久以后,在第一个请求出现一个块之后,您的第二个请求才开始发生,大致与您看到的输出一致.

As you can see it isn't until much later, after a block of the first request occurring, that your second requests start occurring, much along the line of the output you are seeing.

据我对您的问题的了解,您只希望每5秒在所有线程中发生一个请求.要实现此目的,请看恒定吞吐量计时器.恒定吞吐量计时器具有一项设置,可让您在所有活动线程"之间共享其计时器,以便在服务器上创建恒定负载.

From what I understand of your question, you only ever want one request to be occurring every 5 seconds across all threads. To achieve this look at the Constant Throughput Timer. The Constant Throughput Timer has a setting that lets you share its timer across 'All Active Threads' so that you create a constant load on a server.

为了在开始时获得执行顺序,请按照正确的启动时间进行游戏.

In order to get the order of execution at the start correct play about with the ramp-up period.