Apache JMeter Controllers

In Apache JMeter, controllers are fundamental building blocks that define the logic for how test requests are executed. They allow you to structure and control the execution flow of your test plans. Controllers fall into two main categories: Logic Controllers and Samplers. Below is an overview of these controllers:
1. Logic Controllers
Logic Controllers determine the flow of execution in a test plan. They decide how and when child elements (like samplers and other controllers) are executed. Here are the key types of Logic Controllers:
Simple Logic Controllers
Transaction Controller
Groups multiple samplers and treats them as a single transaction, providing metrics for the combined transaction time.
Useful for measuring performance of a sequence of requests.
Recording Controller
Captures and organizes requests when recording traffic using a proxy.
Automatically structures the test plan for easier management.
Flow Control Logic
If Controller
- Executes child elements conditionally based on a JavaScript or JEXL expression.
Loop Controller
Repeats its child elements a specified number of times.
Can also loop indefinitely if needed.
While Controller
Repeats execution as long as a specified condition is true.
Typically used with boolean variables or counters.
Switch Controller
Executes one of its child elements based on a selector value.
Useful for testing different scenarios or variations dynamically.
Run Time Controller
Executes its child elements for a specified duration (e.g., 30 seconds).
Ideal for time-bound performance testing.
Throughput Controller
Controls the percentage of iterations in which its child elements will execute.
Useful for distributing load among different scenarios.
Order and Execution Logic
Module Controller
Allows reusing existing modules (e.g., samplers or controllers) from other parts of the test plan.
Enhances modularity and reusability.
Interleave Controller
- Executes one child element per iteration, cycling through all children in sequence.
Random Controller
- Executes one child element per iteration, selecting randomly from its children.
Random Order Controller
- Executes all child elements in a random order during each iteration.
Advanced Controllers
Include Controller
Includes external JMX files into the current test plan.
Useful for reusing common test components across projects.
Foreach Controller
- Iterates over a set of variables (e.g., a list or array) and executes child elements for each item.
Custom Controllers
- JMeter also supports plugins or custom logic controllers to extend functionality.
2. Samplers
Samplers represent the actual requests sent to the server under test. These include:
HTTP Request Sampler: Sends HTTP/HTTPS requests.
JDBC Sampler: Sends SQL queries to a database.
FTP Sampler: Downloads/upload files via FTP.
SOAP/XML-RPC Sampler: Sends SOAP requests.
JMS Sampler: Interacts with messaging services.
Java Sampler: Executes custom Java code.
How to Use Controllers
Hierarchy: Controllers define the structure of the test plan. For example, a Loop Controllers containing an HTTP Sampler will loop through that request multiple times.
Combination: Controllers can be combined for complex scenarios. For instance:
Use a Transaction Controllers within a Loop Controller to measure repeated transactions.
Use an If Controller to test conditional flows.
Optimization: Controllers help organize test plans, reducing redundancy and improving test readability.
Subscribe to my newsletter
Read articles from Sowkhya directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Sowkhya
Sowkhya
Highly Enthusiastic and Motivated Software Engineer with Hands on Experience/Knowledge in Requirement Gathering ,Developing and Testing an application. Experience in automating, optimizing, streamlining deployment and release processes.