如何在 Jmeter 中生成并发用户负载 [英] How to generate Concurrent User load in Jmeter

查看:20
本文介绍了如何在 Jmeter 中生成并发用户负载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个测试,用户将登录并在搜索字段中输入搜索关键字并获得结果.最后退出.

I have a test where users will logs in and enter search keyword in search field and will get the results. Finally logs out.

现在我想使用 Jmeter 测试并发性.所以这就是我想出的.

Now I want to test concurrency using Jmeter. So this is what I came up with.

Test plan
  Thread group
  + Login request
    + Synchronizing Controller
  + Search string 
    + Synchronizing Controller
  + Logout 

我添加了 10 个线程.我在同步控制器中添加了 5 个.那么当我运行测试时我会得到5个用户的并发吗?剩下的 5 个用户会是同时的用户吗?

I have added 10 in number of threads. I have added 5 in Synchronizing Controller. So when I run the test I will get the concurrency of 5 users? Rest 5 users will be simultaneous users?

当登录页面加载时,我也依赖请求.因此,为了实现登录并发,我在事务控制器中添加了所有请求,并将同步控制器作为子级添加到事务控制器中.如果我做得对,请告诉我.

Also I have depended request when login page loads. So to achieve concurrency on login, I have added all the request in transaction controller and added Synchronizing Controller as child to transaction controller. Please let me know if I am doing it right.

另外请让我知道是否有另一种方法可以实现特定操作的并发(例如:5 个用户同时点击登录按钮).

Also please let me know if there is another way to achieve concurrency for specific action (ex: 5 users hitting login button at same time).

推荐答案

首先,您应该尝试区分并发"和同时".它们通常是非常相似的术语,但在负载测试中它们具有不同的含义.同时意味着同时有两个或多个请求.并发是两个或多个线程(脚本)并行运行.

First off, you should try to distinguish between 'concurrent' and 'simultaneous'. They are normally very similar terms but in load testing they have different meanings. Simultaneous means two or more requests at the same time. Concurrent is two or more threads (scripts) running in parallel.

所以,你说的是尝试配置JMeter来模拟多个并发请求.但实际上,还有一种比这更好的方法.与其专注于尝试同时满足相同的请求(这在 JMeter 中很繁琐),您应该将测试设置为您希望应用程序支持的负载类型的真实表示.如果你做得好,使用随机等待时间、吞吐量控制器和实际数量的线程,那么你将自动测试并发性,同时运行真正、有效和有用的性能测试.

So, what you are talking about is trying to configure JMeter to simulate multiple simultaneous requests. But actually, there's a much, much better approach than this. Instead of focusing on trying to hit the same request at the same time, which is fiddly in JMeter, you should setup your test to be a realistic representation of the sort of load you want your application to support. If you do that well, using random wait times, throughput controllers and a realistic number of threads, then you will automatically be testing concurrency and at the same time running genuine, valid and useful performance tests too.

因此,基本上,放弃同步计时器,改用恒定吞吐量计时器,配置等待时间,然后计算正确的线程数以生成所需的负载.

So, basically, drop the synchronising timer, use a constant throughput timer instead, configure wait times and then calculate the correct number of threads to generate the desired load.

这种方法的额外好处是,您提出假阴性的可能性要小得多.例如,如果您同时使用 5 个登录请求访问您的服务器,那么您可能会发现此调用是单线程的,并且响应时间会增加.但也许这并不重要,也许同时两次登录调用的机会很小,不值得花时间更改代码.这是负载测试中一个非常非常重要的概念——也许是最重要的——你必须有现实的目标,没有这些你可能会运行测试、发现错误的错误并且通常会永远浪费时间.

The added bonus to this approach is you will be much less likely to raise false negatives. For example, if you hit your server with 5 simultaneous login requests then you might find that this call is single-threaded and the response times increase. But maybe this doesn't matter, maybe the chances of two login calls at the same time are so small that it is not worth spending time changing the code. This is a very, very important concept in load testing - perhaps the most important - you must have realistic objectives, without these you could be running tests, finding false bugs and generally wasting time forever.

这篇关于如何在 Jmeter 中生成并发用户负载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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