加特林(和JMeter)努力维持每秒请求数(RPS)? [英] Gatling (and JMeter) struggling to maintain Requests per Second (RPS)?

查看:443
本文介绍了加特林(和JMeter)努力维持每秒请求数(RPS)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在对API进行负载测试.我们遇到了问题-我们的响应时间过长,有时接近一分钟.我们希望在不到一秒的范围内.但这不重要.

I'm load testing an API. We have a problem - our response times are too large, sometimes close to a minute. We want to be at the range of under a second. But that is besides the point.

当我使用诸如Gatling之类的负载测试工具时,发送的RPS似乎停止了.如您在附图中所见,最初有15秒的20RPS,突然之间几乎没有RPS.如何保持恒定的RPS?可能与响应时间短有关,但是如果我不在乎响应时间怎么办?我只想要RPS不变.

When I use a load testing tool, such as Gatling, the RPS sent seem to hit a halt. As you can see in the attached image, there is an initial 15 seconds of 20RPS, and suddenly almost no RPS at all. How can I maintain constant RPS? Probably it has to do with the poor response times, but what if I don't care about the response times? I just want the RPS constant.

我对JMeter的初步测试也显示出类似的行为.

My initial tests with JMeter also show similar behaviour.

推荐答案

在JMeter中,您可以使用恒定吞吐量计时器在您的测试计划级别.

In JMeter, You can achieve that by using Constant Throughput Timer at your test plan level.

恒定吞吐量计时器使您可以维持服务器的吞吐量(请求/秒).恒定吞吐量计时器仅能够暂停JMeter线程,以减慢它们的速度以达到目标吞吐量.而且,它仅在分钟级别上起作用,因此您需要正确地计算加速周期,并让您的测试运行足够长的时间.

Constant Throughput timer allows you to maintain the throughput of your server (requests/sec). Constant Throughput Timer is only capable of pausing JMeter threads in order to slow them down to reach the target throughput. Also, it works only on a minute level so you need to properly calculate the ramp-up period and let your test run long enough.

让我们对此进行简短的思考:

Let's see a brief thought on this:

要实现目标吞吐量,您的测试计划中需要有足够数量的线程.

To achieve the target throughput, you need to have enough number of threads in your test plan.

要计算此测试所需的线程数,可以使用以下公式:

To calculate the number of threads you need for this test, you can use the below formula:

RPS *最大响应时间(秒)

RPS * max response time in second

在您的情况下,如果您想要20 RPS并且最大响应时间是60秒,则您的测试计划中至少需要1200(20*60=1200)个线程.

In your case, If you want 20 RPS and your max response time is 60 seconds, you need at least 1200 (20*60=1200) Threads in your test plan.

由于恒定吞吐量计时器在分钟级别上工作,要实现20 RPS,您必须将"目标吞吐量"值配置为1200/min,并基于"计算吞吐量" 的值为"All active threads".

As Constant Throughput Timer works on a minute level, to achieve 20 RPS you have to configure your "Target Throughput" value to 1200/min and "Calculate Throughput based on" value as "All active threads".

恒定吞吐量计时器配置:

现在,如果您的测试计划中有多个请求(即4 requests),则1200 requests/min将分配在4 samplers中.这意味着您将为每个采样器获得5RPS.

Now, if you have more than single requests in your test plan (i.e 4 requests), then 1200 requests/min will be distributed among 4 samplers. That means you will get 5RPS for each sampler.

现在,对于线程组配置,您已经提到恒定吞吐量计时器"中"All active threads"的基于计算吞吐量" 值,因此需要在服务器上启动所有1200线程才能实现该20 RPS.使用加速期配置来控制这些线程的启动.

Now, for the Thread Group configurations, as you have mentioned "Calculate Throughput based on" value in Constant Throughput Timer for "All active threads", so all of your 1200 threads need to be started on the server to achieve that 20 RPS. Use Ramp-Up Period config to control these threads to start.

加速期是所有线程到达经过测试的应用程序服务器的时间.因此,如果您使用60 seconds,则将需要60秒才能启动所有1200 threads. 60 seconds中将有1200个线程处于活动状态.

Ramp-Up Period is the time in which all the threads arrive on your tested application server. So if you use 60 seconds, then it will take 60 seconds to start all of your 1200 threads. 1200 threads will be active in 60 seconds.

您还需要相应地设置测试持续时间.假设您要将20 RPS保留为5 minutes.在这种情况下,您必须将测试持续时间设置为7 mins(额外的2分钟是:1200个线程的启动时间为1分钟,这是启动时间,而1200个线程的启动时间为最后1分钟).如果您使用的是线程组.

You also need to set your test duration accordingly. Say, you want to keep that 20 RPS for 5 minutes. In this case, you have to set your test duration for 7 mins (2 min extra is for: Starting 1 min for 1200 threads to start which is the ramp up time and last 1 min for the 1200 threads ramp-down time). Don't forget to check the loop counts to Forever if you are using Thread Group.

用于上述情况的线程组配置:

您还可以使用另一个方便的JMeter插件,如果您是最终线程组,与默认的线程组配置混淆.您可以使用 JMeter插件管理器来下载JMeter插件.

You can also use another handy JMeter plugin which is Ultimate Thread Group if you are confused with the default Thread Group configurations. You can download JMeter Plugins by using JMeter Plugins Manager.

以下是上述情况的终极线程组配置:

现在,在测试完成之后,您可以使用5 minutes结果="nofollow noreferrer">每秒的访问数,以及随时间变化的活动线程数.

Now while after the test finishes, you can check those 5 minutes results where all of your 1200 threads were active by using the Hits Per Second Listener and as well as Active Threads Over Time Listener.

请勿使用JMeter GUI进行负载测试,请使用非GUI模式.另外,如果要达到目标RPS,请删除测试计划中的任何断言.

Do not use JMeter GUI for Load testing, use the Non-GUI mode. Also, remove assertions if you have any in your test plan while you're trying to achieve some target RPS.

这篇关于加特林(和JMeter)努力维持每秒请求数(RPS)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆