In performance testing, our goal is to test how real users use an application. If our test does not match real user behaviour, the results may not be correct.
Real users do not always follow the same path. They may repeat actions, skip steps, retry on failure, or choose different options. To handle this, Apache JMeter provides Controllers.
Controllers help us control how requests run in a test. They make test scripts more realistic and organized.
What Are JMeter Controllers?
JMeter Controllers are elements that control the execution of requests. They decide:
- Which request will run
- When it will run
- How many times it will run
They help create logical and meaningful test flows.
Why Are Controllers Important?
In real life, users repeat actions, skip unnecessary steps, follow different paths, retry failed requests, and behave unpredictably. Controllers help simulate these patterns in performance tests.
They make scripts more flexible, realistic, and closer to real-world usage. Without controllers, test plans become simple, rigid, and unreliable.
Simple Controller in JMeter (Basic Execution Control)
The Simple Controller is used to group related requests and improve test plan organization. It works like a folder that helps testers keep similar requests together.
All samplers inside a Simple Controller run in sequence. It does not apply any logic, such as looping or conditions. Its main purpose is to make scripts clean, readable, and easier to manage.
You can add it using:
Thread Group → Add → Logic Controller → Simple Controller



Loop Controller in JMeter
The Loop Controller is used when certain requests need to be repeated multiple times. It allows testers to control how many times selected samplers should run.
All samplers inside the Loop Controller execute in a loop based on the loop count defined. This controller is useful when users perform repeated actions, such as searching multiple times or refreshing pages.
It can be added from:
Thread Group → Add → Logic Controller → Loop Controller



Transaction Controller in JMeter
The Transaction Controller is used to measure the total execution time of multiple requests together. It helps testers analyze the performance of complete business processes such as login, checkout, or order placement.
It groups multiple samplers and calculates their combined response time. When the “Generate Parent Sample” option is enabled, it shows one summarized result for the entire transaction.
You can add it using:
Thread Group → Add → Logic Controller → Transaction Controller



If Controller in JMeter
The If Controller allows requests to run only when a specific condition is true. It works like an “if” statement in programming.
Before execution, it evaluates the given condition. If the condition is true, the samplers inside are executed. If it is false, they are skipped. This controller is useful for creating dynamic user behaviour.
Add it from:
Thread Group → Add → Logic Controller → If Controller



While Controller in JMeter
The While Controller repeats requests as long as a condition remains true. It is mainly used for retry mechanisms and repeated validations.
Before each iteration, it checks the condition. When the condition becomes false, execution stops automatically.
It can be added from:
Thread Group → Add → Logic Controller → While Controller



Throughput Controller in JMeter
The Throughput Controller controls how frequently certain requests are executed. It helps simulate real traffic patterns where some actions occur more often than others.
It can execute requests based on a defined percentage or number of iterations. This controller can be applied per user or globally across all users.
You can add it from:
Thread Group → Add → Logic Controller → Throughput Controller



Once Only Controller in JMeter
The Once Only Controller ensures that specific requests run only once per user, even if the test has multiple loops.
It is commonly used for login or setup actions that should not be repeated. It executes only in the first iteration and skips execution in later loops.
Add it using:
Thread Group → Add → Logic Controller → Once Only Controller



Runtime Controller in JMeter
The Runtime Controller runs requests for a fixed duration instead of a fixed number of loops. It is useful when tests need to run for a specific time period.
Once the defined time expires, the controller automatically stops execution.
It can be added from:
Thread Group → Add → Logic Controller → Runtime Controller



ForEach Controller in JMeter
The ForEach Controller is used to process multiple values stored in variables. It is mainly used in correlation scenarios where multiple values are extracted from responses.
It reads each extracted value and executes the samplers once for every value.
You can add it using:
Thread Group → Add → Logic Controller → ForEach Controller



Random Controller in JMeter
The Random Controller executes one sampler randomly from its child elements. It helps simulate unpredictable user behavior.
During each iteration, JMeter selects one request randomly and executes only that request.
Add it from:
Thread Group → Add → Logic Controller → Random Controller



Interleave Controller in JMeter
The Interleave Controller runs child requests one by one in sequence. In each iteration, it executes the next sampler in order.
This helps distribute requests evenly and simulate balanced user actions.
It can be added from:
Thread Group → Add → Logic Controller → Interleave Controller



Module Controller in JMeter
The Module Controller allows testers to reuse existing test fragments. It helps avoid duplication and improves script maintenance.
It references Test Fragments and executes them wherever needed in the test plan.
You can add it using:
Thread Group → Add → Logic Controller → Module Controller



Conclusion
JMeter Controllers play a vital role in creating realistic and well-structured performance test scenarios. They allow testers to control execution flow, handle dynamic behaviour, and simulate real user journeys effectively.
By using controllers properly, test scripts become more organized, accurate, and maintainable. They help teams identify performance issues early and improve application stability.
















