JMeter Tutorial - How to build a Distributed Load Test (Throughput Controller)
Today we will learn:
1. How to make our samplers run with defined percentage execution. (Distributing the load) 2. How to use Throughput Controller to achieve this. —————————————————————————————————————————
What is a real case scenario ?
Suppose a web application has 3 webpages WEBPAGE A ,WEBPAGE B, WEBPAGE C and a real case scenario will be
- 20% users will access WEBPAGE A
- 45% users will access WEBPAGE B
- 35% users will access WEBPAGE C
Probably the easiest way to implement a distributed scenario like this when N% of users execute task A, M% of users do task B, etc. is setting up
different test groups with the relevant percentage of virtual users configured. For example, given the aforementioned scenario with
20%-45%-35% distribution, we’ll need 3 Thread Groups having 20, 45 and 35 threads correspondingly. So our Test Plan will have:
- Thread Group with 20 users
- Thread Group with 45 users
- Thread Group with 35 users
- A Listener to validate the test
The approach is fairly easy to implement and if your test logic is not very complicated, there won’t be too much overhead in the supporting the thread group per user scenario. In other words, from a perspective of parameterization, you can stick to this option.
But what about distribution requests in a single thread group? We'll need Throughput Controller for this type of distributed scenario.
The Throughput Controller allows the user to control how often it is executed. There are two modes:
- Percent executions : causes the controller to execute a certain percentage of the iterations through the test plan.
- Total executions : causes the controller to stop executing after a certain number of executions have occurred.
Step 1 : Add Thread Group
- Add a Thread Group & name it as Master Thread Group
- For a simple test, lets take 100 threads(virtual users).
Step 2 : Add Throughput Controller
For this test we will consider 3 webpages qaprovider.com/ , qaprovider.com/discussions-club , qaprovider.com/projects
So, we'll need 3 Throughput Controller(1 for each page) to provide the percentage of load to be distributed.
- Add Throughput Controller [Master Thread Group->Add->Logic Controller->Throughput Controller]
- Inside each controller add HTTP sampler & name them as Homepage , Discussion, Projects
- Provide percentage of load for each webpage.
Step 3 : Add Aggregate Report Listener
Aggregate Report will show us the reports of each webpage separately. Add listener [[Master Thread Group->Add->Listeners->Aggregate Report] & run the test.
Here is the result of the test that has been performed under real case scenarios.
Once we provide the percentage to each controller, we can change no. of threads and ramp-up time in the Master Thread Group. This in other ways, reduces our effort & time that we needed for the previous type of test environment(Creating separate thread groups for each page).
Good job. Thank you!