JMeter - 长时间均匀地执行样本

JMeter - Executing samples evenly for long periods

我想执行一个只有 1 个线程组的测试。 我想 运行 n 个不同的线程。假设测试需要 1 秒,那么我可以设置 threads = n 和 ramp up = 1,loop = 1。我的想法是,如果我想让测试 运行 更长,我应该增加 ramp 的数量增加秒数并按相同比例增加循环次数。我在这里读到这个想法:

http://www.testingjournals.com/5-must-know-features-thread-group-jmeter/

在场景 2 的循环部分中,它说: 每 5 秒 (100/20) 4 个线程/请求将到达服务器。

但是没明白是说4个线程平均分布在5秒内,还是每5秒一次发4个请求

如果我想测试这个完全相同的测试但测试时间更长怎么办?我不想要更多线程,因为每个线程都有连接开销。所以我希望相同的 n 个线程在一秒钟内 运行 均匀分布,持续越来越多的秒数。我如何确保相同的线程将被使用并均匀分布在我希望的任何时间范围内?我应该使用恒定吞吐量计时器吗?如果是这样,应该在循环和加速配置中设置什么?

让我们看看场景

– Scenario 2 : Thread Count = 20, Ramp Up Time (Seconds) = 100 & Loop Count = 4 Every 5 seconds (100/20) 4 Thread / Requests will hit the server. Once the first thread completes the first round of execution, it will start 2nd loop by executing same HTTP request. Execution lasts until all 20 threads executes all HTTP requests 4 times.

总共有20个线程,线程将在100秒内平均执行

意思是 100/20 = 5 秒的线程创建间隔

注意循环计数 = 4 然后它将在每个线程内执行请求 4 次

请注意时间是近似的而不是准确的

因此 Ramp up period 适合不创建均匀分布 的新线程。

有关更多受控执行,请参阅 JMeter 插件的 UltimateThreadGroup

"Ultimate" means there will be no need in further Thread Group plugins. The features that everyone needed in JMeter and they finally available:

  • infinite number of schedule records

  • separate ramp-up time, shutdown time, flight time for each schedule record

  • and, of course, trustworthy load preview graph

如果您的目标是每秒执行 X 个请求 - 请选择以下测试元素之一:

以上都可以暂停 JMeter 线程以将吞吐量(每单位时间的请求数)限制为给定数量。关于设置线程组:

  • 线程数:应该足够才能达到目标吞吐量。在 Throughput Shaping Timer 的情况下,您可以使用 Concurrency Thread Group and connect them via feedback function - 在这种情况下,如果当前数量不足以 reach/maintain 所需的每秒请求数,JMeter 将能够自动启动额外的线程
  • 循环:打勾forever
  • 您可以使用线程组中的 Scheduler Configuration -> Duration (seconds) 设置所需的测试持续时间。