Skip to content

Loop Controller

Configure the JMeter Loop Controller logic controllers: properties, defaults, and practical usage notes for building reliable load tests.

Difficulty
intermediate
Guide type
reference
Estimated read time
2 min read
Last verified version
Verified JMeter 5.6

Part of the Logic Controllers category. Also documented in context in the full Component Reference.

TL;DR: the Loop Controller repeats its children a fixed number of times (or forever) within a single thread iteration โ€” the basic building block for โ€œdo this sequence N timesโ€ inside a larger test plan.

Loop Controller

If you add Generative or Logic Controllers to a Loop Controller, JMeter will loop through them a certain number of times, in addition to the loop value you specified for the Thread Group. For example, if you add one HTTP Request to a Loop Controller with a loop count of two, and configure the Thread Group loop count to three, JMeter will send a total of 2 * 3 = 6 HTTP Requests.

NameRequiredDescription
NameNoDescriptive name for this controller that is shown in the tree.
Loop CountYes, unless โ€œForeverโ€ is checkedThe number of times the subelements of this controller will be iterated each time through a test run. The value -1 is equivalent to checking the Forever toggle. Special Case: The Loop Controller embedded in the Thread Group element behaves slightly different. Unless set to forever, it stops the test after the given number of iterations have been done. :::note When using a function in this field, be aware it may be evaluated multiple times. Example using [__Random](/functions/random/) will evaluate it to a different value for each child samplers of Loop Controller and result into unwanted behaviour. :::

Download this example (see Figure 4). In this example, we created a Test Plan that sends a particular HTTP Request only once and sends another HTTP Request five times.

Figure 4 - Loop Controller Example Figure 4 - Loop Controller Example

We configured the Thread Group for a single thread and a loop count value of one. Instead of letting the Thread Group control the looping, we used a Loop Controller. You can see that we added one HTTP Request to the Thread Group and another HTTP Request to a Loop Controller. We configured the Loop Controller with a loop count value of five.

JMeter will send the requests in the following order: Home Page, News Page, News Page, News Page, News Page, and News Page.

  • โ€œForeverโ€ here means โ€œforever within this threadโ€™s iteration,โ€ not โ€œforever for the whole testโ€ โ€” the enclosing Thread Groupโ€™s loop count still governs the outer repetition.
  • Nesting a Loop Controller inside another Loop Controller multiplies iterations (outer ร— inner) โ€” a common source of accidentally-huge request counts when someone forgets an existing outer loop.
  • For conditional repetition instead of a fixed count, use While Controller; for a single conditional branch, use If Controller.
  • See Logic Controllers & Flow Control for how loop, branch, and grouping controllers combine in a realistic test plan.
On this page