使用 JMeter 进行测试:如何每秒运行 N 个请求 [英] Testing with JMeter: how to run N requests per second

查看:18
本文介绍了使用 JMeter 进行测试:如何每秒运行 N 个请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要测试我们的系统是否可以每秒执行 N 个请求.从技术上讲,它是对一个 API 的 2 个请求,对另一个 API 的 2 个请求,以及对第三个 API 的 6 个请求.但重要的是它们应该同时发生 - 所以每秒 10 个请求.因此,在 JMeter 中,我创建了三个线程组,首先定义线程数为 1,启动时间为 0.第二个线程组相同,第三个线程组定义线程数 6 和加速时间 0.但这并不能真正保证它会每秒运行它们我该如何模仿?我如何看待结果——它是否能够执行?

I need to test if our system can perform N requests per second. Technically, it's 2 requests to one API, 2 requests to another, and 6 requests to third one. But the important thing that they should happen simultaneously - so 10 requests per second. So, in JMeter I've created three Thread Groups, first defines number of threads 1, and ramp-up time 0. Second thread group is the same, and third thread group defines number of threads 6 and ramp-up time 0. But that doesn't really guarantee it's going to run them per second How do I emulate that? And how do I see the results -- if it was able to perform or wasn't?

谢谢!

推荐答案

与任何网络测试一样,总会有问题,尤其是延迟问题 - 即使您可以每秒发送 6 个,它们将按顺序发送(这就是数据包的发送方式)并且可能不会在那一秒内全部命中,加上处理时间.

As with any network test, there's always going to be problems, especially with latency - even if you could send exactly 6 per second, they're going to be sent sequentially (that's just how packets get sent) and may not all hit in that second, plus processing time.

通常,当性能指标特定于每秒 x 时,它是在一段时间内测量的.你的 API 甚至可能有一个缓冲区——所以你在技术上可以每秒发送 6 个,但每秒处理 5 个,缓冲区为 20,这意味着 20 秒的流量就可以了,因为你已经发送了 120,这处理需要 120/5 = 24 秒.但除此之外,还会溢出缓冲区.所以仅仅在一秒钟内发送 6 个来测试是不够的.

Generally when performance metrics specific x per second, it's measured over a period of time. Your API may even have a buffer - so you could technically send 6 per second, but process 5 per second, with a buffer of 20, meaning it'd be fine for 20 seconds of traffic, as you'd have sent 120, which would take 120/5 = 24 seconds to process. But any more than that would overflow the buffer. So to just send exactly 6 in a second to test is insufficient.

在线程组中,您将线程(用户)的数量设置为 6 是正确的.然后永远循环运行它(勾选它或将其放入 while 循环中)并添加一个监听器,如聚合报告和结果树.您可以用来检查发送和响应的内容是否正确的结果(假设您验证了响应),并且在汇总报告中,您可以看到每小时发生的每个活动的数量(显然乘以 3600 秒,但是由于这种不准确,最好运行很长时间).

In the thread group, you're right setting number of threads (users) to 6. Then run it looping forever (tick it or put it in a while loop) and add a listener like aggregate report and results tree. The results you can use to check the right stuff is being sent and responded to (assuming you validate the responses) and in the aggregate report, you can see how many of each activity is happening per hour (obviously multiply by 3600 for seconds, but because of this inaccuracy it's best to run it for a good length of time).

现在可以运行初始负载测试,作为更准确的测试,您可以让它运行更长时间(浸泡测试),以查看是否存在任何其他问题 - 缓冲区溢出、内存泄漏或其他意外事件.

The initial load test can now be run, and as a more accurate test, you can leave it running for longer (soak test) to see if any other problems surface - buffer overflows, memory leaks, or other unexpected events.

这篇关于使用 JMeter 进行测试:如何每秒运行 N 个请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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