In this article, Lets see how we can distribute the load across the critical scenarios of the application using Throughput Controller in JMeter.
Overview:
Identifying the Critical business transactions is an important phase in order to create a proper workload model for our Performance Test. We had already published an article on Performance Workload Modeling using Little’s law. If you have not read that, I would suggest you to read that article first.
Tools like Google Analytics can help us in finding the frequently visited pages of our application & the percentage of user load among these pages. This information provided by the tool needs to be thoroughly reviewed by Performance tester with the help of Business side Product owners / Project managers / BA / Application Architect etc to confirm the scenarios to be tested and user load distribution.
Once the script is created & verified, user load has to be distributed in the test plan in such a way that it mimics the Production behavior.
User Load Distribution:
Lets consider a simple application with below functionalities.
- Flight Search
- New User Registration & Book flight
- Existing User Login & Book flight
- Admin User Login & Edit Ticket
- Admin User Login & Cancel Ticket
If our requirement is to test the above application with 100 concurrent users, we can not distribute the load like 20 users per functionality. We will know that users who are all searching for a flight will not book the ticket. So, We will have more users on a flight search page than the ‘booking a flight’ page.
Lets assume that among 100 concurrent users,
- 90% of total users on the application are searching for flights
- 30 users are booking tickets
- 50% of them are new users – so they go through the registration process
- 50% of them are existing users – they simply login and book the ticket
- Login page is common for both regular and admin users
- 30 users are booking tickets
- 10% of users on the application are admin users
- 60% of admin users are modifying the flight as per the user request
- 40% of admin users are cancelling the ticket as per the user request
Note: % in the below diagram shows the % of total users who accessed the application.
Throughput Controller:
Lets assume we already have created & verified the scripts for these business functionalities like Search / Login / Book etc. However we need to use appropriate controller to distribute the load to simulate production like behavior. That is where Throughput Controller comes into picture.
The name of the controller seems to mislead – It does not actually control the throughput of the application server. If that is what you are looking for, You need to take a look at Constant Throughput Timer.
Throughput controller has below options to control the execution of the samplers
- 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.
To understand this behavior better, I create a quick test plan in JMeter as shown below.
Total Executions:
I create a Test Plan like this with 1000 concurrent users.
Even if we had 1000 users, only 100 samplers were executed – remaining 900 threads have not sent any request as the Throughput Controller total execution limit has been reached already.
Percent Executions:
I modify the Test Plan like this with 1000 concurrent users.
Because of the ‘Percent’ execution, out of 1000 concurrent users, 600 threads executed Sampler A and while others were sending request B.
For our requirement of above flight search application, I would be using Percent Execution option and per user checkbox would be unchecked – Because the percent is among all VUsers, Not per user.
We can place Throughput controller inside another Throughput Controller. If I modify the test plan as shown below, that is, 60% of total threads will execute A. Only 40% of 60% will execute B. So we get result as shown below.
Workload Modeling:
If we take a look at the above user load distribution diagram, our requirements are,
- 90% of total users on the application are searching for flights
- So we need to add a Throughput controller with 90% execution. There should be a sampler for Search request.
- 30 users are booking the flight.
- Only 90% of the users are actually searching for flight.
- 30 users from 90 users is 33.333%
- 50% of 33.333% of total users are new users = 16.67%
- 50% of 33.333% of total users are existing users = 16.67%
- 10% of users on the application are admin users
- 60% of admin users are modifying the flight as per the user request
- 40% of admin users are cancelling the ticket as per the user request
Test Results:
I run the test for 100 concurrent users – Page visits have been distributed as per our requirement.
When i run the same test for 10000 concurrent users, Page visits are still as per our requirements due to ‘Percent Execution’ option of Throughput Controller.
Summary:
We are able to model our workload as per the Production behavior using Throughput Controller instead of creating multiple Thread Groups. In the above test plan, I might have redundant ‘Book’ sampler. But in the actual test plan, we need to keep group the samplers based on the user action on the application using Transaction Controller. These Transaction Controllers will be kept in the reusable Test Fragments. We would call these fragments using Module Controller to avoid any redundancy.
Check below articles for more information.
- JMeter – Run specific Thread Group on specific Environment
- JMeter – Creating Modular / Reusable Test Scripts
Happy Testing & Subscribe 🙂
Very useful, with this can replicate real user scenarios easily. Thanks for sharing.
thanks alott its more informative,One query i have if i have want to increase or decrease certain number users or transactions how can we achieve in Jmeter tool unlike in Neoload or Loadrunner tool we have a option .Can you suggest any work around or possible ways to decrease or increase users while running the test rather than stopping the test
Take a look at the Ultimate thread group which could decrease and increase the users