本文介绍了如何在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 

线程数。我在同步控制器中添加了5。所以当我运行测试我将获得5个用户的并发性? Rest 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?

此外,我在登录页面加载时依赖请求。所以为了实现并发登录,我已经添加了所有的请求在事务控制器和添加Synchronizing Controller作为子到事务控制器。请让我知道,如果我做的正确。

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).

推荐答案

首先,你应该尝试区分'concurrent'和'simultaneous'。它们通常是非常相似的术语,但在负载测试中,它们有不同的含义。同时表示同时两个或更多请求。并发是两个或多个并行运行的线程(脚本)。

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的fiddly,你应该设置你的测试是一个现实的表示负载你希望你的应用程序支持。如果你这样做,使用随机等待时间,吞吐量控制器和一个现实的线程数,那么你将自动测试并发,同时运行正确,有效和有用的性能测试。

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个同时登录请求访问服务器,那么您可能会发现此调用是单线程的,并且响应时间增加。但也许这没关系,也许两个登录调用在同一时间的机会是如此之小,以至于不值得花时间更改代码。这是负载测试中一个非常非常重要的概念 - 也许是最重要的 - 你必须有现实的目标,没有这些,你可以运行测试,发现错误的bug,并永远浪费时间。

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中生成并发用户负载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 06:00