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

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

问题描述

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

谢谢!

解决方案

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

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

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

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

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?

Thanks!

解决方案

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.

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.

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天全站免登陆