How to control the business ratio in the JMeter test plan

Source: Internet
Author: User

In the performance test mix scenario, we need to combine multiple business operations into the scene.
For example, there is a forum where the business is distributed as follows:
The ratio of new posts to replies is 2:3,
So how do we control the proportions of the JMeter test plan?

Here are two ways of doing it:


1. Multi-threaded Group mode

2. Logic Controller Control

Multithreaded Group mode:

We know that JMeter uses thread groups to emulate virtual users, and JMeter can also support multiple thread groups in a plan.


Using this feature, we can put the new post business in a thread group, the reply business is placed in another thread group.


To create a proportional relationship of business volume, we achieve results by controlling the number of threads. Such as:


Replaytopic for the reply thread group, add 90 threads;
Sendtopic to open a new thread group, add 60 threads, just 3:2

Of course, this can only be approximate, if the response time of the two transactions is not the same, the final percentage of the number of completed business will be different.


The current number of threads is assumed to be the same as the two business response times, so this is a perfectly ideal situation.


It can be seen that this way of control is not perfect.

Here's a 2nd way:

Controller control

is an if controller, the if controller can use an expression as a condition, so that we get to the number of iterations to determine


is a reply or open a post, such as a total of 3 iterations, the 1th and 3rd iterations when the new posts, the three-fold iteration will be replies


Now we're going to get the number of iterations, and the JMeter function helper provides a __counter function that can be used to get the current
The number of iterations.

Well, we have the idea, the number of iterations can also be obtained, how to maintain the ratio of 3:2? This is a math problem.


Do not sell the view, directly on the code:
${__counter (True,)}%2==1| | ${__counter (True,)}%3==0
The above __counter (true) is the number of times the current iteration is obtained, and the% is the remainder, which is the execution of a new post, except that 2 is divisible by 1 and 3.


Take 9 iterations For example, replies 9 times, 1,3,5,6,7,9 times will open a new post, back to just 6 times


9:6=3:2

Basically protects the ratio by 3:2.

Reprint to: http://mp.weixin.qq.com/s?__biz=MjM5Mjg0MzMzMw==&mid=210023366&idx=2&sn= A6868ea94bb2c5794b99cc455ad5ee17&scene=1&srcid=09137euoiki9zpfcxyb6zzny#rd

How to control the business ratio in the JMeter test plan

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.