How to use Logic Controllers in JMeter? Types of Controllers, When to use and Practical Hands On Exercise

JMeter Logic Controllers determine when to process the Samplers. In simple terms, JMeter Logic Controllers control the order of Samplers execution.

In the topic JMeter Elements, we covered a brief overview of JMeter Controllers. In this topic, we will discuss Logic Controllers in more detail.

JMeter supports many type of Logic Controllers, this tutorial describes the most common logic controller. We will go through a practical, hands on exercise after we give an overview of some of the Logic Controllers.JMeter_Logic_Controllers_Tutorial

Types of Controllers in JMeter

Simple Controller

If your Test Plan has many Samplers and Controllers you may need to manage and organize them. Simple Controller allows you do this. Simple Controller is like a storage device, which contains Samplers and Controllers. JMeter_Logic_Simple_Controller_How_To_Use

It does not provide any other benefit apart from organizing Samplers and Controllers. In order to organize elements, you just need to create a Simple Controller and add the child elements under your Simple Controller.JMeter_Logic_Simple_Controller

Loop Controller

Loop controller loops the request a certain number of times based on its Loop Counter. It can also loop forever, if required.JMeter_Loop_Controllers_Tutorial

This is an example of Loop Controller

You create one HTTP request and add it as a child element to Loop Controller with Loop Count = 4. JMeter will send 4 HTTP requests to server.JMeter_Logic_Loop_Controller

In the above example, if the Thread Group of the HTTP Request sampler had a loop count of 3, then the total number of times the request would be invoked = 4 x 3 = 12

Recording Controller

Recording Controller works like Simple Controller. It is a place to store the recordings when using the HTTP(S) Test Script Recorder (which was earlier known as the HTTP Proxy Server). All the samples of the recording are saved in it, when you record a test script.JMeter_Recording_Controllers_Tutorial

It does not have any configuration settings.

Runtime Controller

Runtime Controller allows the user to set how long its child Samplers can run.JMeter_Runtime_Controllers_Tutorial

For example, if you add an HTTP Request sampler to a Runtime controller and set the runtime to 10 seconds. This request will run for 10 seconds.

Module Controller

The purpose of module controller is to add modularity to JMeter.

For example: If a web app under test contains units of functionality such as Login, Orders, and Checkout. Each those functionalities can be stored in module. Module Controller allow user to select which module to run.JMeter_Module_Controllers_Tutorial

Include Controller

If you have many test plans which are stored in local drive (*.jmx file). You can include them into current Test Plan by using Include Controller.

Include Controller allow users to “merge” many test plans into one.

In below figure, we include the exist test plan in Test Plan.jmx to current Test PlanJMeter_Include_Controllers_Tutorial

Practical Hands On Exercise with Controllers

In this practical exercise, you will learn how to use a Run Time Controller in your performance tests.

The scenario for this test is below:

  • Create a HTTP request to
  • Setting the time limit for the test to run
  • Send the request to Google server

The workflow for the practice exercise is as follows:JMeter_Logic_Runtime_Controllers_Tutorial

Step 1. Add a Thread Group

Start JMeter and add a Thread Group to the default Test Plan as explained in previous topics. Set the properties as follows: Number of threads – 1, Ramp-Up Period – 1 second, Loop Count – 1. In this exercise, we simulate only one user connecting to Google’s server.JMeter_Runtime_Controllers_Tutorial_Training1

Step 2. Add Runtime Controller

Right click Thread Group and choose Add > Logic Controller > Runtime ControllerJMeter_Runtime_Controllers_Tutorial_Training2

Set the Runtime Controller’s run time to 3 seconds.JMeter_Runtime_Controllers_Tutorial_Training3

This means that JMeter will send the requests to Google server for 3 seconds. After that time, it will stop sending the requests.

Step 4. Add HTTP Request Sampler

Add a HTTP Request Sampler under the Runtime Controller. Right click on the Runtime Controller, select Add > Sampler > HTTP Request Sampler. Set the Server name to

In this example we have named the sampler – Visit Home Page.

Step 5. Add View Result Tree Listener

Add a View Result Tree Listener to Thread Group. Click on Thread Group, choose Add > Listener > View Results Tree.

Step 6. Run the Test Plan

Click the Run button in menu bar, you will see the Test Running in View Result Tree pane. After 3 seconds, the test will stop. JMeter_Runtime_Controllers_Tutorial_Training_4_Results

If you change time Runtime to be longer (for example 10 seconds), you will see the test run longer.JMeter_Runtime_Controllers_Tutorial_Training_10sec_Results

You can download the sample JMeter Runtime Controller Test Plan used in this tutorial to practice on your machine. It already has all the setting explained above.

In the next topic you will learn how to use Timers in JMeter.