Loop Count in JMeter

Loop Count in JMeter

One small number decides how many times every virtual user repeats its journey. Get it right and your load test is honest and repeatable. Get it wrong and the whole test can end too soon, never end at all, or quietly send ten times more traffic than you planned.

Think about a gym instructor who tells a class, “Do this exercise ten times.” Everyone starts, everyone counts, and everyone stops when they reach ten. Now imagine the instructor forgets to say the number. Some people stop after five. Some keep going until they collapse. The class turns into chaos, and nobody can compare results.

Performance testing has the same need for a clear number. When a JMeter test sends pretend users to your website, each one has to know how many times to repeat its steps. That number is the Loop Count. It looks like a tiny field in a settings panel, yet it quietly controls the length of your test, the total number of requests, the amount of test data you need, and even how trustworthy your final report is.

This guide starts from the very first idea and builds up to the habits of experienced performance engineers. You will learn what the Loop Count is, how it differs from similar settings, how JMeter counts loops inside its engine, how it works with duration, data files, timers, and distributed testing, and which mistakes to avoid.

1What Is Loop Count?

The Loop Count is the number of times each virtual user repeats the full set of steps placed under a Thread Group.

The Simple Definition

In Apache JMeter, a Thread Group creates virtual users, and each virtual user is called a thread. Every thread follows the same list of steps, such as opening the home page, searching for an item, and logging out. The Loop Count is a field on the Thread Group that says how many times a thread should go through that whole list before it stops.

If the Loop Count is one, each user does the journey once and leaves. If it is ten, each user does the journey ten times in a row. If you tick the Infinite box next to it, the user keeps going without a fixed count, and something else must decide when to stop.

Everyday Analogy

Imagine a runner on a running track. The track is the list of steps, and each full lap is one iteration. The Loop Count is the number of laps the coach asks the runner to complete. One lap is a quick jog. Ten laps is a proper workout. Infinite laps means the runner keeps circling until the coach blows the whistle.

One Word You Must Know: Iteration

An iteration is one complete pass through the steps. People often say “loop” and “iteration” to mean the same thing. If a user logs in, views a product, adds it to a basket, and logs out, that is one iteration. A Loop Count of five means five iterations for each thread.

i
Remember

The Loop Count belongs to each thread separately. If you have fifty threads and a Loop Count of ten, every one of the fifty threads does ten loops. The total is five hundred iterations, not ten.

2Why Loop Count Exists

To see why we need this setting, imagine a load test without it.

The Problem

A single trip through a website is over in seconds. If every virtual user did just one trip and left, your test would be finished almost at once, and you would learn very little. Servers behave differently when they have been working for a while. Caches fill up. Connection pools warm up. Memory slowly grows. Slow problems only show themselves after many repeated requests.

You need a way to keep users busy for long enough to see the true behaviour. You also need a way to control exactly how much work each user does, so that two test runs can be compared fairly. The Loop Count solves both problems with one number.

What It Gives You

Control

Test Length

More loops mean a longer test. Fewer loops mean a quicker one. It is the simplest way to stretch or shrink a run.

Control

Total Volume of Requests

Threads multiplied by loops multiplied by steps tells you exactly how many requests you will send.

Control

Repeatability

A fixed count gives the same amount of work every time, so you can compare today with last week.

Control

Data Planning

It tells you how many accounts, product codes, or search words your test files must contain.

Real-World Motivation

A bank that wants to confirm its payment service can process one hundred thousand payments in an evening window needs a test that sends a known, fixed number of payments. Teams in that situation work backwards from the business number to the thread count and Loop Count. Without a clear loop setting, they could not say how many payments the test actually attempted.

3Core Concepts You Need First

A few words appear again and again. Learn them once and the rest becomes easy.

Test Plan and Thread Group

The Test Plan is the whole saved test, stored in a file with the extension .jmx. A Thread Group sits directly under it and controls the crowd of virtual users: how many there are, how fast they start, and how many times they repeat.

Sampler

A sampler is one action that sends a request to the system being tested and measures the answer. The most common is the HTTP Request sampler. A single iteration usually contains several samplers.

Logic Controller

A logic controller decides the order and conditions of the steps. Some controllers repeat their children. The most important one for this topic is the Loop Controller, which has its own loop count that works inside the larger loop of the Thread Group.

Think Time

Real people pause between actions. This pause is called think time, and JMeter creates it with timers. Think time decides how long one iteration takes, and that decides how many iterations fit into a given amount of time.

Infinite Loop

When the Infinite box is ticked, the Loop Count has no limit. The thread will keep repeating until another rule stops it, such as a time limit on the Thread Group, a stop action after an error, or a manual stop by the tester.

TermPlain MeaningWhere You See It
ThreadOne virtual userNumber of Threads field
IterationOne full pass through the stepsCounted by the Loop Count
Loop CountHow many iterations each thread performsThread Group panel
InfiniteNo fixed number of loopsCheckbox beside Loop Count
Loop ControllerRepeats only the steps inside itUnder a Thread Group
SamplerOne request sent and measuredUnder a Thread Group or controller
Think timeA human-like pause between actionsTimers

4Architecture and Where Loop Count Sits

A JMeter test is a tree. The Loop Count lives on the branch that decides how often everything beneath it runs.

The Test Plan is the root of the tree. The Thread Group is a branch below it, and the Loop Count is a setting on that branch. Everything placed under the Thread Group is part of one iteration. When a thread finishes the last step, JMeter checks the Loop Count. If more loops remain, the thread jumps back to the first step. If not, the thread ends.

flowchart TD
    TP["Test Plan"] --> TG["Thread Group: Loop Count = 5"]
    TG --> ONCE["Once Only Controller: Login"]
    TG --> LC["Loop Controller: Loop Count = 3"]
    LC --> S1["Sampler: View Product"]
    LC --> TM["Timer: Think Time"]
    TG --> S2["Sampler: Add To Basket"]
    TG --> S3["Sampler: Logout"]
    TG --> LS["Listener: Summary Report"]
    
Figure 1: Thread Group loop count and a Loop Controller nested under it

Reading the Diagram

In the picture, the Thread Group repeats five times. Inside each of those five iterations, the Loop Controller repeats its own steps three times, so the product page is viewed three times per iteration and fifteen times per thread. The login is placed under a Once Only Controller, so it runs only on the first iteration. The basket step and the logout run once per iteration.

!
Multiplication Rule

When loops are placed inside loops, the counts multiply. A Thread Group loop of five and a Loop Controller of three means the inner steps run fifteen times for each thread.

Analogy: A Washing Machine

Everyday Analogy

A washing machine has a program with steps: fill, wash, rinse, spin. The Thread Group loop count is how many times you run the whole program. A Loop Controller is like asking the machine to repeat only the rinse step three times inside each program. If you run the program five times with three rinses each, you get fifteen rinses.

5The Loop Count Field and the Infinite Checkbox

The panel looks tiny, but every field beside the Loop Count changes how it behaves.

The Loop Count Field

You type a whole number. One means a single pass. Ten means ten passes. Zero is a trap: a Thread Group with a Loop Count of zero does no iterations, so threads start and immediately end, and your report will be empty. If your report is empty and you cannot see why, check this field first.

The Infinite Checkbox

When you tick Infinite, JMeter ignores the number in the field. The thread repeats until something else ends it. Infinite loops are popular for timed tests, where you want the load to stay steady for, say, thirty minutes no matter how fast or slow each iteration is.

!
Watch Out

Infinite with no duration, no stop action, and no manual stop means the test never ends. Many beginners start such a test and walk away. Always pair Infinite with a duration on the Thread Group.

Neighbouring Settings That Change the Meaning

Several other fields sit beside the Loop Count, and each one interacts with it.

  • Number of Threads says how many users repeat the loops.
  • Ramp-up period says how far apart the thread starts are. It does not change how many loops each thread performs.
  • Same user on each iteration decides whether a thread keeps its cookies and session between loops.
  • Specify Thread lifetime adds a duration and a startup delay.
  • Action after a sampler error can end the loops early if you choose a stop option.
1
loop means one pass, then done
N
loops means N passes per thread
Infinite
needs another rule to stop

6The Arithmetic of Loops: Counting Total Requests

A good tester always knows how many requests a test will send before pressing start.

The Basic Formula

The total number of requests equals the number of threads, multiplied by the Loop Count, multiplied by the number of samplers that run in one iteration. If a Loop Controller or an If Controller changes how many samplers run, use the real number for each pass.

Total requests = threads x loop count x requests per iteration

Worked Example One

You have 50 threads, a Loop Count of 10, and each iteration contains 4 samplers. The total is 50 times 10 times 4, which equals 2,000 requests. If the server answers each request in about half a second, and users pause two seconds between steps, one iteration takes roughly ten seconds, so each thread needs about a hundred seconds, plus the ramp-up time.

Worked Example Two

You have 200 threads, a Loop Count of 20, and an iteration with 8 samplers. The total is 200 times 20 times 8, which equals 32,000 requests. If your test data file supplies one account per iteration, you need 200 times 20, which is 4,000 accounts, or you must allow the file to be reused.

ThreadsLoop CountSamplers Per IterationTotal IterationsTotal Requests
11414
105450200
501045002,000
2002084,00032,000
5003121,50018,000

Why This Matters

Systems under test often have limits that matter beyond load, such as daily message quotas, rate limits, or the cost of every call to a paid service. A few seconds with a calculator can stop you from sending a million messages by accident.

i
Pro Tip

Write the expected total requests in the test plan’s comment field. When the report shows a very different number, you know at once that something stopped early or ran longer than planned.

7Loop Count Versus Duration: Who Wins?

There are two ways to end a thread: by counting laps or by watching a clock. Understanding how they combine is essential.

Counting Laps

With a fixed Loop Count, each thread stops after its last iteration. A fast server finishes the test sooner, and a slow one makes it last longer. The amount of work stays the same, but the length of the test changes.

Watching a Clock

With Infinite loops and a duration, each thread keeps going until time runs out. The length of the test stays the same, but the amount of work changes. A fast server completes more iterations in the same time, and a slow one completes fewer.

When Both Are Set

If you set a finite Loop Count and also set a duration, each thread stops at whichever limit comes first. A thread that finishes its loops early ends early, and a thread still running when the clock runs out is stopped by the clock.

Fixed Loop Count

  • Same amount of work every run
  • Easy to plan data and totals
  • Good for functional-style checks and batch scenarios
  • Test length depends on server speed

Infinite With Duration

  • Same test length every run
  • Steady load for as long as you need
  • Natural fit for steady-state and soak tests
  • Total requests vary with server speed
flowchart TD
    Q1{"What is your goal?"} --> A["Fixed amount of work, like 10000 orders"]
    Q1 --> B["Steady load for a fixed time, like 30 minutes"]
    Q1 --> C["Quick check that a script works"]
    A --> A1["Use a finite Loop Count and calculate threads times loops"]
    B --> B1["Use Infinite loops with a Duration"]
    C --> C1["Use 1 thread and Loop Count of 1"]
    
Figure 2: Choosing between a fixed Loop Count and Infinite loops with a Duration
Everyday Analogy

A coach can say, “Run ten laps,” or “Run for thirty minutes.” The first fixes the distance and lets the time vary. The second fixes the time and lets the distance vary. Both are valid training plans, but they answer different questions.

8Thread Group Loop Count Versus Loop Controller

Two things share the name “loop count,” and mixing them up is one of the most common beginner errors.

The Thread Group Loop Count

This setting repeats the entire set of steps under the Thread Group, for each thread. It is the outer loop. The whole journey, from first sampler to last, is run again each time.

The Loop Controller

The Loop Controller is a separate element that you add under a Thread Group. It repeats only its own children. It has its own Loop Count field and its own Infinite checkbox. It is the inner loop, used to repeat part of the journey, such as viewing several products or paging through several result pages.

FeatureThread Group Loop CountLoop Controller
What repeatsEverything under the Thread GroupOnly the steps inside the controller
Where you set itThread Group panelLoop Controller panel
Typical useRepeat the whole journeyRepeat part of a journey
Effect on thread lifeDecides when the thread endsDoes not end the thread
Counting when nestedOuter countMultiplies with the outer count

An Example That Shows the Difference

You want each user to log in once, view ten products, and log out. The right design is a Thread Group with a Loop Count of one, and a Loop Controller of ten around the product view. The wrong design is a Thread Group with a Loop Count of ten containing login, product view, and logout. That version logs in ten times and logs out ten times, which puts ten times more load on the login service than you intended, and it distorts every result about login.

!
Watch Out

When a Thread Group loop count is greater than one, everything inside it, including login and logout, repeats. If something should happen only once per user, use a Once Only Controller or a Loop Controller design.

9How JMeter Counts Loops Internally

Understanding the engine room helps you predict what your test will do and why it sometimes surprises you.

Every Thread Keeps Its Own Counter

When you start a test, JMeter reads the Test Plan and makes a private copy of the Thread Group’s contents for every virtual user. Each thread is a real Java thread running inside the JMeter process. Each one also keeps its own loop counter. Thread number seven has no idea what thread number eight has done. This is why a Loop Count of ten gives each thread its own ten loops, rather than ten loops shared among all of them.

The Decision at the End of Each Pass

At the end of every iteration, the thread asks a simple question: “Do I have loops left?” JMeter also asks other questions at the same moment: “Has my duration run out?” and “Did someone ask the test to stop?” If every answer says to continue, the thread goes back to the first step and begins the next iteration. If any answer says to stop, the thread ends and its results remain in the report.

sequenceDiagram
    participant E as JMeter Engine
    participant T as Virtual User Thread
    participant C as Loop Counter
    participant S as Server Under Test
    E->>T: Start thread at ramp-up time
    T->>C: Set counter to Loop Count
    loop Until counter reaches zero or time ends
        T->>S: Run samplers of one iteration
        S-->>T: Return responses
        T->>E: Report sample results
        T->>C: Reduce counter by one
    end
    T->>E: Thread finished
    
Figure 3: How one virtual user counts its loops during a run

What Resets and What Does Not

At the start of a new iteration, some things are renewed and some are kept. The position in the script goes back to the beginning. Controllers that keep per-iteration state, such as the inner Loop Controller, begin their counting again. Thread variables, cookies, and caches are kept or cleared depending on the “Same user on each iteration” setting, which we cover in a later chapter.

Why Counters Are Per Thread

Keeping a counter per thread makes the engine fast and simple. No thread has to wait for another to update a shared number. The price is that JMeter cannot easily say, “Run exactly one thousand iterations in total, split among whatever threads are free.” For that kind of goal, you need a special tool such as the Throughput Controller in its total-executions mode, which we discuss later.

i
Good to Know

The ramp-up period only decides when each thread begins. Once a thread has started, its loops run at the pace of the server and the timers. A thread that starts late still does the full Loop Count, so the test lasts until the last-starting, slowest thread finishes.

10Data Flow and the Life of an Iteration

Follow one virtual user through its loops and the whole mechanism becomes clear.

flowchart TD
    A["Thread starts after its ramp-up delay"] --> B["Loops remaining?"]
    B -- "No" --> Z["Thread ends"]
    B -- "Yes" --> C["Read next row of test data"]
    C --> D["Run samplers in order"]
    D --> E["Wait for think time between steps"]
    E --> F["Check responses with assertions"]
    F --> G{"Error happened?"}
    G -- "Yes, stop action chosen" --> Z
    G -- "No or continue chosen" --> H{"Duration finished?"}
    H -- "Yes" --> Z
    H -- "No" --> I["Reduce loop counter"]
    I --> B
    Z --> L["Results collected by listeners"]
    
Figure 4: Life cycle of a virtual user that repeats its steps according to the Loop Count
1

Check Remaining Loops

Before any work, the thread checks whether it still has loops left. With a Loop Count of zero, it stops right here.

2

Load Data

Config elements such as the CSV Data Set supply this iteration’s values, like a username.

3

Do the Work

Samplers fire in order, each measured from send to complete answer.

4

Pause Like a Person

Timers add think time, which stretches the length of each iteration.

5

Judge the Answers

Assertions decide whether responses were really correct, and the error action decides what happens after a failure.

6

Count Down and Repeat

The loop counter goes down by one, and the thread returns to the top unless a stop rule applies.

Where the Time Goes

The length of one iteration equals the sum of all response times plus all think times plus a small amount of processing inside JMeter. Multiply that by the Loop Count to estimate the working life of a thread. Add the ramp-up delay to estimate when the last thread will finish.

11Once Only Controller and the Login-Once Pattern

Some steps should happen only on a user’s first lap. The Once Only Controller makes that easy.

The Problem It Solves

Real users log in once and then do many things. If you place a login step directly under a Thread Group with a Loop Count of twenty, each thread logs in twenty times. That is not how people behave, and it distorts your results by hammering the login service far more than reality.

How the Once Only Controller Works

The Once Only Controller runs its children during the first iteration of each thread and skips them in every later iteration. So you place the login under this controller, and the rest of the journey beside it. Thread one logs in on its first loop, and from the second loop onwards, it goes straight to the real work.

Everyday Analogy

Think of a visitor who enters an office building. The visitor signs in at the front desk on arrival, and then walks around the offices many times. Nobody signs in again every time they return to a room. The front desk is the Once Only Controller, and the wandering is the loop.

An Alternative Design

Another approach is a setUp Thread Group that logs in and stores a token, or a Thread Group with a Loop Count of one that contains an inner Loop Controller around the repeating steps. The right choice depends on whether each virtual user needs its own login. If every user needs a personal session, the Once Only Controller inside the main group is simplest. If all users share one token, a setUp group is cleaner.

Once Only Controller

  • Simple to set up
  • Each user has a personal login
  • Keeps one Thread Group easy to read

Things To Watch

  • Works per thread, so login still happens once for every thread
  • Session expiry during very long loops needs handling
  • Behaves differently if “Same user on each iteration” is unchecked
!
Watch Out

If you uncheck “Same user on each iteration,” cookies are cleared at the start of each new loop. A user who logged in during the first loop could then appear logged out in loop two, even though the Once Only Controller correctly skipped the login.

12Same User on Each Iteration

This small checkbox decides whether a thread behaves like one person returning or a new stranger each time.

What the Checkbox Does

When “Same user on each iteration” is checked, the thread keeps its state between loops. Cookies, cached items, and authorization details stay in place. The thread behaves like one real person who keeps using the application.

When it is unchecked, JMeter clears this state at the start of every new loop. The thread behaves like a brand-new visitor each time. Cookies are gone, so the server treats the thread as a new session.

Which One Should You Choose?

Checked

Logged-In Users

Choose it when a user logs in once and then performs many actions, as with a banking or shopping session.

Unchecked

Anonymous Visitors

Choose it when each loop represents a different visitor, such as people arriving at a public news site.

Effect

Caching

A returning user may have cached files and so request less. A new visitor downloads everything, which is heavier on the server.

Effect

Server Sessions

Unchecked loops create many sessions on the server, which tests session storage much harder than a few long sessions.

An Example With Numbers

You have 100 threads and a Loop Count of 10. With the box checked, the server sees about 100 long sessions, each doing ten rounds of work. With the box unchecked, the server sees about 1,000 short sessions. The total number of requests may be equal, but the pressure on session memory, login code, and cache behaviour is very different.

i
Pro Tip

Decide this setting by asking, “What does one loop represent in real life?” If one loop is one person’s whole visit, uncheck it. If many loops are one person’s long visit, check it.

13Loop Count and Test Data Files

Every extra loop wants fresh data. If your data runs out, your test may stop, repeat, or fail in surprising ways.

How Many Rows Do You Need?

The CSV Data Set Config element feeds each iteration with a row from a file, such as a username and password. If every iteration consumes one row and all threads share the file, you need one row for each iteration in the whole test. That equals the number of threads multiplied by the Loop Count.

Rows needed = threads x loop count

What Happens When Data Runs Out

The CSV Data Set Config has two settings for the end of the file. Recycle on EOF sends the reader back to the first row, so data is reused. Stop thread on EOF ends the thread when the data finishes. If you set neither, reaching the end of the file gives threads a placeholder value of “EOF,” and your requests quietly use the wrong data. This is a very common cause of strange failures near the end of a test.

Recycle on EOFStop Thread on EOFBehaviour When Rows Run Out
TrueFalseStarts again from the first row
FalseTrueThread ends, which can shorten your test
FalseFalseVariables receive a marker value, and requests probably fail
TrueTrueRecycling is applied, so threads keep going

Sharing Mode and Loops

The sharing mode decides who shares the file pointer. In “All threads” mode, every thread takes the next unused row, so each row is used once until recycling. In “Current thread group” mode, each Thread Group has its own pointer. In “Current thread” mode, every thread reads the file from the beginning. With many loops, the wrong sharing mode can make two users log in with the same account at the same moment, and servers that block repeated logins will reject them.

A Practical Case

A team tests a ticket-booking service with 300 threads and a Loop Count of 5. They need 1,500 unique ticket codes, because each code can be used only once. They prepare a file with 1,600 codes, set the file to stop threads at the end, and keep the sharing mode on all threads. The test finishes cleanly, and no code is ever used twice.

14Counters and the Iteration Number

Often you want to know which loop you are in, to create unique names or change behaviour over time.

The Counter Config Element

JMeter offers a Counter config element that produces a growing number. You choose a starting value, an increase for each use, and a variable name. This number can be placed into requests, for example to build unique order references or names.

Two options matter most. Track counter independently for each user gives each thread its own count, which then matches the loop number. If unchecked, all threads share one count, and the number rises across the whole test. Reset counter on each Thread Group iteration sends the count back to its start at the beginning of every loop, which is rarely what you want for unique names.

Iteration Index From Controllers

Newer JMeter versions record an index variable for loop-style controllers, named after the controller. This lets you read which pass of an inner loop you are on, starting from zero. Names and details can vary between versions, so check the documentation for your version before relying on it.

Using the Iteration Number Wisely

  • Build unique names so repeated loops do not clash, for example a new basket name per iteration.
  • Vary search words or page numbers, so every loop does slightly different work, which is closer to real behaviour.
  • Switch behaviour after a warm-up number of loops, for example ignoring early loops in your analysis.
!
Watch Out

A shared counter that is not independent per user can produce gaps and duplicates in distributed runs, because every worker keeps its own copy. If you need globally unique values across workers, add a worker-specific part to the value, or use data files that are split by worker.

15Loop Count, Think Time, and Pacing

Loop Count tells you how many laps. Think time and pacing tell you how fast each lap goes.

Iteration Time

The time of one iteration is the sum of every response time plus every pause. If a journey has four requests that each take half a second, and three pauses of three seconds, then one iteration lasts about eleven seconds. A Loop Count of ten makes each thread live for about 110 seconds.

The Request Rate Each Thread Produces

A thread making four requests every eleven seconds produces about 0.36 requests per second. One hundred such threads produce about 36 requests per second. If you remove all think time, the same iteration might last only two seconds, and each thread would produce two requests per second. The Loop Count did not change, but the pressure on the server is five times higher.

11 s
one iteration with think time
110 s
life of a thread at 10 loops
36 / s
requests per second from 100 threads

Pacing: Keeping Each Lap the Same Length

Pacing means starting each iteration at a fixed interval, no matter how long the work took. For example, “begin a new iteration every thirty seconds.” If the server is fast, the thread waits for the rest of the interval. If the server is slow, the next iteration begins as soon as the last one ends. Pacing holds the rate steady, so a slower server does not accidentally reduce the load it receives. In JMeter you can achieve a similar effect with a throughput-oriented timer, or with a timer that adds a pause at the end of each iteration.

Everyday Analogy

A bus runs on a timetable and leaves every thirty minutes, whether the last trip was quick or slow. That is pacing. A taxi leaves as soon as the last customer is dropped. That is a loop with no pacing. The first gives a steady flow of departures. The second depends on how busy the previous trip was.

16Running an Exact Total of Iterations

Sometimes the goal is a fixed total, such as one thousand orders, no matter how many threads share the job.

Why the Loop Count Alone Does Not Do It

Each thread repeats the same number of times. If you want exactly 1,000 orders and you have 40 threads, you can set a Loop Count of 25. That works only when 1,000 divides evenly by the number of threads. With 30 threads, 1,000 does not divide evenly, and you must accept a small difference, or find another approach.

Throughput Controller in Total Executions Mode

The Throughput Controller can run its children a fixed number of times across all threads. In its “Total Executions” mode, with the “Per User” box unchecked, it counts executions for the whole test. Once the total is reached, it stops running its children. Threads keep looping with an infinite Loop Count but they skip the controller, so the work stops at exactly the number you chose.

Combine this with a stop action or a short duration, so that threads do not keep spinning idly after the work is done.

Other Ways to Reach a Fixed Total

  • Choose threads and loops that multiply to the total. For 1,000 orders, use 50 threads and 20 loops, or 100 threads and 10 loops.
  • Use a data file with exactly that many rows and set threads to stop at the end of the file. The data decides the total.
  • Use a Throughput Controller with a percentage mode to run a step only for a share of iterations, such as five percent of users buying.
GoalGood Approach
Exactly 1,000 orders, evenly splitThreads times Loop Count equals 1,000
Exactly 1,000 orders, uneven splitThroughput Controller with total executions
One order per customer recordData file with stop thread on end of file
Five percent of visits end in a purchaseThroughput Controller in percent mode

17Breaking Out of Loops and Stopping Early

Sometimes a loop should end before its count is finished. JMeter offers several safe ways to do that.

Error Actions on the Thread Group

The Thread Group has a setting called “Action to be taken after a Sampler error.” Its choices decide how failures affect your loops.

  • Continue ignores the error and carries on with the next step.
  • Start Next Thread Loop abandons the rest of this iteration and begins the next one, which is useful when a failed login makes later steps pointless.
  • Stop Thread ends this one user and all its remaining loops.
  • Stop Test and Stop Test Now end the whole test, either gently or immediately.

While Controller

The While Controller repeats its children as long as a condition is true. It is the right tool for “keep checking until the order status says complete,” a pattern called polling. Always give it a limit or a sleep, so that a condition that never becomes false does not trap the thread forever.

Flow Control Action

The Flow Control Action sampler lets you stop or redirect in the middle of a journey. Its options include going to the next iteration of the current loop, breaking out of the current loop, starting the next thread loop, stopping the thread, or stopping the test. You place it inside an If Controller so that it only acts when a certain condition happens, such as a missing token.

Choosing the Right Exit

1

A Step Fails But Others May Work

Choose Continue. Real users keep going after an error page, and your report should show those errors.

2

A Failed Login Makes the Rest Pointless

Choose Start Next Thread Loop, so the user tries again from the top.

3

One User Is Broken Beyond Repair

Choose Stop Thread, so one bad account does not spoil the whole run.

4

The Target System Is Down

Choose Stop Test, so you stop flooding a dead server and protect your results.

18Infinite Loops and How to Stop Them Safely

Infinite loops are powerful for timed tests, and dangerous when nothing is set to end them.

Why People Use Infinite Loops

A steady-state test usually says, “Hold this load for thirty minutes.” The most natural way to build that is Infinite loops with a duration of thirty minutes. Each thread keeps working no matter how fast the server is, so the load is steady for the whole period. A fixed Loop Count would let fast threads end early and leave the system with less load near the end of the test.

The Ways an Infinite Test Can End

  • Duration. The Thread Group’s own time limit stops each thread when the clock runs out. This is the cleanest option.
  • Error action. A stop setting after an error can end a thread or the whole test.
  • Manual stop. The tester presses stop in the window, or sends a shutdown command to a non-GUI run. A gentle shutdown lets running requests finish, while an immediate stop interrupts them.
  • Data end. A data file set to stop threads at its end can finish the test when data is exhausted.
  • Controllers. A Throughput Controller that has reached its total, combined with a Flow Control Action, can end threads.
!
Watch Out

An infinite test with a result listener that stores every sample in memory can slowly eat all the memory on the test machine, then crash. Long tests must write results to a file, not keep them in the window.

A Safe Checklist Before You Start an Infinite Test

1

Duration Is Set

Confirm that the Thread Group has a duration, and that the duration is longer than the ramp-up.

2

Results Go to a File

Make sure heavy listeners are off and a results file is being written.

3

Side Effects Are Safe

Check that endless loops of orders or emails will not harm a real system or a real person.

4

You Know the Stop Plan

Know how to shut the test down quickly and who to tell if something goes wrong.

19Loop Count in Distributed Testing

When you add more machines, every setting, including the Loop Count, is applied on each of them.

Every Worker Runs the Whole Plan

In JMeter’s distributed mode, a controller machine sends the Test Plan to several worker machines. Each worker runs the full plan exactly as written. If a Thread Group has 100 threads and a Loop Count of 10, each worker runs 100 threads for 10 loops. With three workers, the server sees 300 threads and 3,000 iterations.

Planning the Totals

WorkersThreads Per WorkerLoop CountTotal ThreadsTotal Iterations
1100101001,000
3100103003,000
540102002,000
45052001,000

To hit a target total, divide the threads or the Loop Count by the number of workers before you set the fields. Most surprises in distributed tests come from forgetting this step.

Data Files Across Workers

Each worker reads its own copy of the data file, and each copy begins from the first row. That means two workers can use the same account at the same moment. To avoid it, give each worker a different slice of data, for example separate files named for each machine. Counters also run separately on each worker, so values that must be unique across the whole test should include something that identifies the worker.

i
Pro Tip

Pass the loop count and thread count as named properties when starting each worker, instead of typing fixed values into the plan. That way one test file can serve one machine or ten, and you change only the start commands.

20Performance and Scalability Effects of Loops

More loops do not just mean longer tests. They change what your test machine and your target system experience.

Effects on the Test Machine

  • Memory growth. Every completed sample may be stored by listeners. With many loops, the number of samples grows quickly. Heavy listeners can fill memory long before the test ends.
  • Processor use. Parsing responses and running scripts happens on every iteration. Cheap scripts become expensive when repeated millions of times.
  • Result file size. A test that sends millions of requests produces a large results file. Plan disk space, and consider saving only the fields you need.
  • Network connections. If each iteration opens new connections, the machine can run out of network ports. Reusing connections helps.

Effects on the System Under Test

  • Warm caches. Early loops hit cold caches. Later loops hit warm ones. Averages that include early loops can look worse than steady behaviour.
  • Slow leaks. A system that leaks memory or connections may look healthy for ten loops and fail after ten thousand.
  • Data growth. Loops that create orders or records make databases bigger, which can slow later loops.
  • Garbage collection and compaction. Many platforms run clean-up work periodically. Longer tests reveal these pauses that short tests miss.
Short
loops show cold start behaviour
Medium
loops show steady behaviour
Long
loops reveal leaks and drift

Warm-Up Loops

A common tactic is to run a small warm-up first. You can create a separate Thread Group for warm-up, run it before the main group using the option to run Thread Groups one after another, and exclude its results from your analysis by giving its samplers a different name or using a separate results file. Another way is to run the main test and study only the steady part afterwards.

21Monitoring, Logging, and Metrics for Looping Tests

A repeated test creates a long story. Good metrics let you read it.

Numbers to Watch

MetricWhat It Tells You About Loops
Samples countShould equal your calculated total. A difference means threads stopped early or ran longer.
Active threads over timeShows when threads finished and whether load stayed steady.
Response time over timeA rising line across loops suggests leaks or growing data.
Throughput over timeShould stay near flat in a steady test. Drops show trouble.
Error percentage over timeErrors that appear only in later loops often point to data or session problems.
PercentilesShow how the unlucky users fared across all loops.

Compare Early Loops and Late Loops

One of the most valuable habits is to compare the first tenth of a test with the last tenth. If response times double, something is accumulating on the server. If errors start only near the end, data may have run out, sessions may have expired, or a disk may have filled up.

Server Side Monitoring

JMeter measures what users see. To find causes, also collect server numbers such as processor use, memory, disk, database connections, and queue lengths over the same period. Line up both views on one timeline, and the cause of a slow rise during later loops is usually easy to spot.

Logging Your Settings

Always record the thread count, Loop Count, duration, and ramp-up for every run, next to the results. Numbers without settings cannot be compared later. A tiny text file saved with each results file is enough.

22Security and Safety With Repeated Requests

Loops multiply every action. Anything harmful done once becomes much worse when done ten thousand times.

Only Test What You Are Allowed To Test

Sending a flood of requests to a system you do not own, or have no written permission to test, may be illegal and can be treated as an attack. Even inside your own company, tell the operations team and anyone sharing the environment before you start a long, looping test.

Side Effects Multiply

  • A loop that creates an order creates thousands of orders. Use a test environment with test payment settings, and clean up afterwards.
  • A loop that sends an email or text message can message real people many times. Point it at test addresses or a mail sink.
  • A loop that registers accounts can fill databases with junk. Plan clean-up in a tearDown Thread Group.
  • A loop that calls a paid service can run up a large bill.

Account Lockouts and Defences

Security systems watch for repeated logins and suspicious behaviour. A loop that logs in again and again with the same account can lock it, or trigger rate limiters and firewalls. Plan with the security team, use enough different test accounts, and be clear in your report about whether defences were active during the test.

Protect Credentials and Data

Test data files often contain usernames and passwords. Do not use real customer data. Keep files out of public places, and do not share results files that contain sensitive responses.

!
Watch Out

The most expensive mistakes in load testing come from loops that were left running. Always know the stop plan before you start, and never leave an infinite test unattended against a system with real side effects.

23Advantages, Disadvantages, and Trade-Offs

Every approach has strengths and weaknesses. Knowing both helps you choose well.

Advantages of Loop Count

  • Very simple to understand and configure
  • Gives a predictable, repeatable amount of work
  • Makes total requests easy to calculate
  • Works with every kind of sampler and protocol
  • Combines cleanly with controllers, timers, and data files
  • Helps reveal slow problems that single passes hide

Disadvantages of Loop Count

  • Each thread repeats the same number, so uneven totals need extra tools
  • Test length varies with server speed
  • Fast threads finish early and reduce load near the end
  • Infinite mode needs a separate stop rule
  • Everything under the group repeats, including steps meant to run once
  • Easy to multiply nested loops by accident

Key Trade-Offs

ChoiceOne SideOther Side
Fixed loops or durationFixed work, variable timeFixed time, variable work
Few long sessions or many short sessionsTests steady logged-in useTests session creation and login
Few loops or many loopsQuick, shows cold startSlow, reveals leaks and drift
Reuse data or unique dataEasy, may flatter cachesRealistic, needs large files
Pacing or no pacingSteady rate under slow serversSimple, but load falls when the server slows

24Design Patterns and Anti-Patterns

Experienced testers keep returning to a few shapes that work and a few traps that fail.

Patterns That Work

Pattern

Smoke Loop

One thread and one loop to prove the script works before scaling.

Pattern

Timed Steady State

Infinite loops with a duration, for a stable load over thirty to sixty minutes.

Pattern

Fixed Batch

A calculated Loop Count so that threads times loops equals the exact volume you want to process.

Pattern

Login Once, Work Many

A Once Only Controller for login, and a Loop Controller for repeated actions.

Pattern

Soak Loop

A long, moderate load that repeats for hours to find memory and connection leaks.

Pattern

Warm-Up Then Measure

A short warm-up group first, then the main group, with analysis based only on the main one.

Traps to Avoid

ANTI-PATTERN 01 Avoid
What It Looks Like

A tester sets Infinite loops and no duration, starts the test, and goes home.

Why It Hurts

The test never ends. It can fill memory, flood the system with side effects, and spoil the results with a huge, meaningless tail of data.

Better Approach

Always pair Infinite with a duration, results written to a file, and a known stop plan.

ANTI-PATTERN 02 Avoid
What It Looks Like

Login, work, and logout are all placed directly under a Thread Group with a high Loop Count.

Why It Hurts

Each loop logs in and out again, producing far more login traffic than real users would, and skewing every login-related metric.

Better Approach

Use a Once Only Controller for login, a Loop Controller for the repeated work, and place logout after the loop.

ANTI-PATTERN 03 Avoid
What It Looks Like

The data file has only a hundred rows, while the test needs ten thousand, and no end-of-file behaviour is chosen.

Why It Hurts

After row one hundred, threads receive a marker value, and requests start failing for reasons that have nothing to do with the server.

Better Approach

Calculate rows needed as threads times loops, then prepare enough data or choose recycling on purpose.

25Best Practices and Common Mistakes

Habits that save time and protect the trustworthiness of your results.

Best Practices

1

Calculate Before You Run

Write down threads, loops, samplers per iteration, and the expected total requests. Compare it with the report afterwards.

2

Match the Loop Style to the Goal

Use fixed loops for fixed work, and Infinite with a duration for steady load.

3

Keep One-Time Steps Out of the Loop

Use Once Only Controllers, setUp groups, or inner Loop Controllers so login and setup happen the right number of times.

4

Prepare Enough Data

Rows needed equal threads times loops, plus a small margin.

5

Parameterise Loop Settings

Let the loop count and duration come from named properties, so the same test can run small or large.

6

Run in Non-GUI Mode With Light Listeners

Long looping tests must write results to a file and avoid heavy listeners.

7

Study Early Versus Late Loops

Compare the start and end of the test to spot drift, leaks, and data problems.

Common Mistakes at a Glance

MistakeResultFix
Loop Count of zeroEmpty reportSet at least one
Infinite with no durationTest never endsSet a duration or stop rule
Forgetting nested loops multiplyFar more requests than plannedCalculate the product of all loops
Login inside the main loopToo many loginsUse a Once Only Controller
Not enough data rowsLate failures from marker valuesPrepare threads times loops rows
Ignoring worker multiplicationLoad multiplied by number of workersDivide settings by workers
Heavy listeners with many loopsMemory exhaustionWrite results to a file instead

26Real-World Examples

These scenarios show how loop settings change with the goal. They describe how teams at well-known kinds of companies commonly think, and they are illustrations, not claims about any company’s private tools.

A Retail Giant Rehearsing a Big Sale

A very large online retailer wants to rehearse a sale day. The team builds a Thread Group with Infinite loops and a sixty-minute duration, so the load stays steady for the whole hour. Inside each iteration, a Loop Controller views several products, which matches real browsing. They compare the first ten minutes with the last ten to check that response times do not drift upward.

A Payment Company Processing a Fixed Batch

A payment company has to confirm that its system can handle exactly two hundred thousand test payments in one night. The test uses a fixed Loop Count, with threads times loops equal to the target. A data file with unique payment references feeds each iteration, and threads stop when data ends, so the total is exact.

A Streaming Service Testing Sign-In

A streaming service expects many people to sign in within one hour after a big release. To test the sign-in service, each loop represents a different visitor, so “Same user on each iteration” is unchecked and sessions are created fresh every time. The load shows how session storage and login code cope with huge numbers of short sessions.

A Ride-Hailing App Looking for Slow Leaks

A ride-hailing company suspects a slow memory leak in its dispatch service. The team runs a moderate soak test with Infinite loops for eight hours. Early loops look healthy, but after five hours, response times climb. That slow rise is exactly what a ten-minute test would never have shown.

A Small Start-Up Checking Launch Readiness

A start-up with one web server runs fifty threads with a Loop Count of twenty and realistic think time. The test shows errors from the thirteenth loop onwards. The cause turns out to be a database connection pool that is never released. A short single-pass test would have missed it entirely.

27Setting Up Loop Count Step by Step

Reading is helpful, but building makes it stick. Follow these steps in order.

1

Add a Thread Group

Right-click the Test Plan, choose Add, then Threads (Users), then Thread Group. Name it clearly, such as “Shoppers”.

2

Set a Tiny Loop Count First

Use one thread and a Loop Count of one. Add a single HTTP Request and a debugging listener, and run it to prove the script works.

3

Raise the Loop Count to Three

Run again with one thread and three loops. The listener should show three copies of each request. If it does, you understand the basic counting.

4

Add a Loop Controller

Place a Loop Controller under the Thread Group, move one sampler inside it, and set it to two. With a Thread Group Loop Count of three, that sampler should now appear six times.

5

Add a Once Only Controller

Move a login step inside a Once Only Controller. Run again, and confirm that login appears once, while the other steps repeat.

6

Try Infinite With a Duration

Tick Infinite, enable the thread lifetime option, and set a duration of sixty seconds. Run, and confirm the test ends by itself after about one minute.

7

Scale Up Carefully

Increase threads in steps, calculate expected totals each time, and compare them with the report. Switch to non-GUI mode and light listeners for real runs.

i
First-Day Habit

After every run, compare the number of samples in the report with the number you calculated. If they match, you understand your test. If they differ, find out why before you trust any other number.

28A Worked Example: Choosing Loop Count for a Real Goal

Let us design the loop settings for a realistic test, from business goal to final numbers.

Step 1: State the Goal

An online store wants to prove that its checkout service can run at 20 completed checkouts per minute for 30 minutes, with 95 percent of requests answering within two seconds. That means a total of 600 checkouts over the test.

Step 2: Estimate the Iteration Time

One checkout journey has five requests: view the basket, enter the address, choose shipping, pay, and confirm. Each takes about 0.6 seconds on average, which gives 3 seconds of server time. The journey includes four pauses of 5 seconds each for reading and typing, which gives 20 seconds of think time. One iteration lasts about 23 seconds.

Step 3: Use Little’s Law for Threads

The target rate is 20 checkouts per minute, which is one checkout every three seconds, or about 0.33 per second. Using the idea that users in the system equal the arrival rate multiplied by the time spent, we need about 0.33 multiplied by 23, which is roughly 7.7. Round up to 8 threads, and add a small margin, so 10 threads will do.

Step 4: Choose Fixed Loops or a Duration

The goal talks about “30 minutes,” so the natural choice is Infinite loops with a duration of 30 minutes plus the ramp-up. If instead the goal were “exactly 600 checkouts,” a fixed count would fit: 10 threads times 60 loops is 600 iterations.

ItemOption A: Timed TestOption B: Fixed Batch
Threads1010
Loop CountInfinite60
Duration1,800 seconds plus ramp-upNot needed
Expected iterationsAbout 780 (10 threads, 1,800 s, 23 s each)600
Test data rowsAt least 850 with marginAt least 600 with margin
Best forSteady load for a fixed timeAn exact amount of work

Step 5: Check the Rate Matches the Goal

Option A produces about 780 checkouts in 30 minutes, which is 26 per minute, higher than the 20 per minute target. To match the target exactly, add pacing so each thread starts a new iteration every 30 seconds, which gives 10 threads times 2 iterations per minute, equal to 20 per minute. This shows why thread count and loop count alone do not control rate. Pacing or a throughput timer does.

i
Interview Insight

When asked how you would set the Loop Count, walk through the reasoning: goal, iteration time, threads by Little’s Law, fixed work versus fixed time, data rows, and pacing for rate. It shows structured thinking, not guesswork.

29Troubleshooting Loop Problems

When loops misbehave, the cause is nearly always one of a small set of familiar suspects.

SymptomLikely CauseWhat To Do
Report is emptyLoop Count of zero, or a disabled Thread GroupSet at least one loop and enable the group
Test never endsInfinite loops with no duration or stop ruleAdd a duration, or stop the test manually
Far more requests than plannedNested loops multiplying, or a group repeating setup stepsMultiply all loop counts and check what sits inside each loop
Fewer requests than plannedThreads stopped early because of an error action or data endCheck the error action and file settings
Test ends earlier than the durationA finite Loop Count finished before the time was upUse Infinite loops for timed tests
Failures only in late loopsData ran out, sessions expired, or the server is leakingCheck data rows, session length, and server metrics
Same account used by many usersWrong sharing mode on the data fileUse a sharing mode where each user takes a new row
Login traffic too highLogin placed inside the repeating sectionUse a Once Only Controller
Users appear logged out in later loops“Same user on each iteration” is uncheckedCheck it for logged-in journeys

A Simple Debugging Routine

Shrink the problem. Use one thread, a Loop Count of three, and a debugging listener. Count how many times each sampler appears. The numbers will quickly show you whether a controller is repeating something or skipping something. Fix the structure first, then scale.

Everyday Analogy

If a music box plays the wrong tune, you do not turn the handle faster. You slow down and listen to a few notes at a time. Debugging loops works the same way: look at three laps carefully before trying three thousand.

30Settings That Beginners Often Confuse

Many wrong results come from mixing up two things that sound alike.

Loop Count and Ramp-Up

Loop Count says how many times each thread repeats. Ramp-up says how far apart threads begin. A long ramp-up does not make the work slower, and a larger Loop Count does not make threads start later.

Loop Count and Duration

Loop Count limits repetitions. Duration limits time. When both are set, whichever is reached first stops the thread. Using a small finite Loop Count together with a long duration often leads to tests that end long before the duration, which confuses people who expected a steady load for the whole time.

Thread Group Loop and Loop Controller

The Thread Group Loop Count repeats the whole journey. The Loop Controller repeats only the steps inside it. Nested together, they multiply.

Iteration, Sample, and Request

An iteration is a full pass through all the steps. A sample is one measured action. A request is usually the same as a sample in a web test. One iteration contains many samples. Reporting “ten thousand iterations” and “ten thousand requests” are two very different statements.

Same User and Once Only

Once Only decides which steps run during the first iteration only. “Same user on each iteration” decides whether cookies and caches survive from one loop to the next. They are independent, but they work together: a Once Only login helps only if the session is kept by the “same user” setting.

PairFirst MeaningSecond Meaning
Loop Count and ramp-upHow many lapsHow far apart threads start
Loop Count and durationLimit by countLimit by time
Group loop and Loop ControllerRepeats the whole journeyRepeats part of it
Iteration and sampleA full passOne measured action
Once Only and same userRuns first loop onlyKeeps cookies across loops
i
Self-Check Before You Press Start

Say out loud how many threads there are, how many loops each does, how many requests are in one loop, and what the expected total is. If you cannot answer in a few seconds, the test is not ready.

31A Case Study: The Test That Ended Too Soon

This story is a composite of problems that engineering teams commonly meet. It shows how a small loop choice can produce a big wrong conclusion.

The Situation

A team wants to prove their order service can hold a steady load of 200 users for forty minutes. A junior engineer sets 200 threads, a ramp-up of 300 seconds, a Loop Count of 5, and a duration of 2,400 seconds. Each iteration takes about forty seconds.

What the Report Said

The report showed healthy response times and no errors. The engineer declared success. Later, a senior colleague noticed that the whole test had lasted only about eight minutes and that the load graph looked like a hill, not a plateau.

What Was Really Happening

1

The Loop Count Ended Threads Early

Five loops at forty seconds each is 200 seconds of work per thread. The 2,400-second duration was never reached, because every thread finished long before.

2

The Ramp-Up Was Longer Than a Thread’s Life

Threads started over 300 seconds, but each lived only 200 seconds. The first threads were gone before the last ones started, so the system never saw 200 users at once.

3

No Steady State Existed

With threads starting and ending constantly, the load never held at a plateau. The numbers described a gentle hill, not the forty-minute steady load the team had promised.

How the Team Fixed the Test

They ticked Infinite, kept the duration at forty minutes, and shortened the ramp-up to five minutes. Active threads now rose to 200 and stayed there. The new report showed that response times drifted upward after twenty-five minutes, because a cache on the server slowly filled and slowed lookups. This was a real finding that the first, misleading test had completely hidden.

i
The Lesson

Always look at the active threads graph. It shows what your loop settings really produced. A test that looks successful may simply not have run the load you thought it did.

32Glossary of Terms

Keep this page handy. Every word here appears somewhere in the guide.

TermPlain Meaning
AssertionA check that decides whether a response was correct
ControllerIn distributed mode, the machine that sends the plan to workers
DurationHow long a Thread Group is allowed to run
Flow Control ActionA sampler that stops or redirects a loop on a condition
Infinite loopA loop with no fixed number, ended by another rule
IterationOne full pass through the steps
Logic controllerAn element that decides order and repetition of steps
Loop ControllerA controller that repeats only its own children
Loop CountHow many iterations each thread performs
Once Only ControllerA controller that runs its children on the first iteration only
PacingStarting each iteration at a fixed interval
Ramp-upThe time JMeter takes to start all threads
SampleOne measured action by a sampler
Soak testA long test with steady load to find slow leaks
Steady stateThe stable part of a test after ramp-up
Think timeA human-like pause between actions
ThreadOne virtual user in JMeter
Throughput ControllerA controller that runs its children a set share or number of times
While ControllerA controller that repeats while a condition is true
WorkerA machine that runs the plan under a controller machine

33Parameterising Loop Count for Automation

Modern teams run performance tests again and again, not only once before a launch. Fixed numbers typed into a panel make that hard.

Why Parameterise

Imagine one test file that must serve three purposes: a two-minute smoke check after every code change, a twenty-minute check every night, and a two-hour soak before a big release. If the Loop Count and duration are typed into the Thread Group, you need three copies of the file, and they will slowly drift apart as people edit one but not the others. A better approach is to let the numbers come from named properties.

How It Works in Plain Words

JMeter lets you start a test from the command line and pass in named properties, such as the number of threads, the Loop Count, and the duration. Inside the Thread Group fields, you use a property function that reads the named property and falls back to a sensible default if none was supplied. When you open the test by hand, the defaults make it behave as a tiny smoke test. When the pipeline starts it, the real numbers arrive from outside.

Run TypeThreadsLoop CountDurationPurpose
Smoke23Not usedProve the build works, on every change
Nightly50Infinite20 minutesCatch slow regressions early
Soak100Infinite2 hoursFind leaks before a release
Fixed batch50200Not usedProcess an exact volume

A Typical Pipeline Flow

1

Deploy to a Test Environment

The pipeline builds the application and puts it in an environment that resembles production.

2

Start JMeter Without the Window

JMeter runs from the command line with the chosen properties, and writes results to a file.

3

Check the Totals

A small script compares the number of samples with the expected total. A mismatch means threads ended early or something ran too long.

4

Check the Limits

The script compares percentiles and error percentage with limits the team agreed on, and fails the build if they are broken.

5

Keep the Evidence

The report and raw results are stored with the build, so anyone can compare today with last week.

i
Keep Pipeline Tests Honest

Short pipeline loops detect large regressions quickly, but they cannot replace a long soak. A leak that takes five hours to show will never appear in a five-minute check.

34Loops in Other Kinds of Thread Groups

The standard Thread Group is not the only way to shape load. Other groups treat repetition differently.

The Standard Thread Group

This group has the Loop Count field and the Infinite checkbox we have studied. Each thread repeats its steps on its own until the count, the duration, or a stop rule ends it. It follows what is called a closed model: the number of users is fixed, and each user starts a new trip only after finishing the last one.

setUp and tearDown Groups

These special groups also have loop settings, but they are normally kept at one. A setUp group prepares things before the main test, such as creating test data or fetching a token. A tearDown group cleans up afterwards. Both usually run once, because you want preparation and clean-up to happen exactly one time.

Plug-In Groups With Schedules

Plug-in groups, such as the Ultimate Thread Group and the Concurrency Thread Group, replace the Loop Count with a schedule. You describe how many users there should be, and for how long, and the group keeps threads busy repeating their steps for as long as the schedule demands. In effect, these groups use infinite loops with a clock. Their shape is controlled by time, not by a loop number.

The Open Model Thread Group

The Open Model Thread Group, found in newer versions, goes one step further. You do not say how many users loop. You say how fast users arrive, for example ten per second for five minutes, and each arriving user performs the steps once. The “loop” is replaced by the arrival rate. This is a strong fit for public websites, where visitors arrive whether or not the server is busy.

Group TypeHow Repetition Is ControlledBest For
Standard Thread GroupLoop Count or Infinite with durationMost everyday tests
setUp and tearDownUsually a single passPreparation and clean-up
Ultimate Thread GroupA table of timed waves of usersComplex shapes with ramp-down
Concurrency Thread GroupA target of active users over timeHolding steady concurrency
Open Model Thread GroupAn arrival rate schedulePublic traffic where visitors do not wait for each other
Everyday Analogy

The standard group is a fixed team of runners who each run a set number of laps. A scheduled group is a coach who sends runners out and calls them back according to a plan on a clipboard. An open model is a stadium where new fans keep walking in at a steady rate, each watching the match once and leaving.

!
Watch Out

Plug-in groups are installed separately, usually through the JMeter Plugins Manager. If you share a test file, make sure teammates have the same plug-ins, or the file will open with missing elements.

35Reporting on Looping Tests Honestly

Repetition creates a lot of data. How you summarise it decides whether your report is trusted.

Do Not Blend Warm-Up With Steady State

The first loops of a test run against cold caches and half-open connection pools. They are often slower than the loops that follow. If you average everything together, the early slow loops drag your numbers around. Where possible, report the steady part separately, and mention the warm-up in a note.

Use Transactions for Readable Reports

One iteration may contain many requests, and a report that lists each one has hundreds of lines. A Transaction Controller groups requests into one named business step, such as “Checkout.” Your report then shows one line per step, with one response time that matches what a person would feel. Remember to say whether numbers refer to samples or to transactions.

Report the Settings Next to the Numbers

  • Threads, Loop Count or duration, and ramp-up.
  • Expected and actual total samples.
  • Number of workers, if distributed.
  • Whether think time and pacing were used.
  • Whether the environment had security defences active.

Show the Trend, Not Only the Average

A single average hides what loops reveal. Include a chart of response time across the whole run, and one of active threads. The first shows drift, and the second proves that the load you describe is the load you really produced.

A number without its settings is only a rumour.

Be Honest About Limits

If the test ended early, say so. If data was recycled, say so. If some loops hit errors from the test machine rather than the server, say so. Honest reports build trust, and trust is what makes performance results useful when real decisions depend on them.

36Quick Reference: Choosing Loop Settings at a Glance

When you are in a hurry, use this page to pick the right loop settings for the job in front of you.

If Your Goal IsLoop Count SettingAlso SetWatch For
Check that a script works1 thread, Loop Count of 1A debugging listenerTurn the listener off before scaling up
Check that counting works1 thread, Loop Count of 3A debugging listenerEach sampler should appear three times
Hold steady load for a fixed timeInfiniteDuration, results fileDuration must be longer than the ramp-up
Send an exact amount of workFinite, threads times loops equals the targetEnough data rowsUneven division of the total
Find slow leaksInfinite, long durationServer monitoring, light listenersMemory growth on the test machine
Test sign-in with many short sessionsFinite or InfiniteSame user on each iteration uncheckedAccount lockouts and defences
Test logged-in users doing many actionsModerate countOnce Only login, same user checkedSession expiry in long loops
Hit an exact total with uneven threadsInfiniteThroughput Controller in total executions modeThreads idling after the total is reached
Run on several machinesDivide by the number of workersSeparate data for each workerTotal load equals workers times per-worker load

Five Questions to Ask Before Every Run

Question 1

What Is the Total?

Can you state the expected number of iterations and requests in one sentence?

Question 2

What Ends the Test?

Is it the loop count, the duration, the data, or a stop rule, and do you know which will come first?

Question 3

What Repeats?

Is anything inside the loop that should happen only once, such as login or setup?

Question 4

Is There Enough Data?

Do you have threads times loops rows, or have you chosen what happens at the end of the file?

Question 5

Is It Safe?

Will thousands of repetitions harm anything real, such as customers, bills, or shared systems?

i
Final Habit

After every run, put two numbers side by side: the total you expected and the total you got. When they agree, you understand your loops. When they disagree, you have just found the most useful clue of the whole test.

37Frequently Asked Questions

Quick answers to the questions beginners ask most.

Q1What is the default Loop Count?
A new Thread Group usually starts with a Loop Count of one, which means each thread does a single pass. Check the field in your version, and always set it on purpose rather than trusting the default.
Q2Does the Loop Count apply to all threads together or to each one?
It applies to each thread separately. Fifty threads with a Loop Count of ten make five hundred iterations in total.
Q3What does the Infinite checkbox do?
It removes the fixed number of loops. Threads keep repeating until a duration, a stop action, a data end, or a manual stop ends them.
Q4What happens if I set the Loop Count to zero?
Threads start and end without running any steps, so the report is empty. It is a common cause of “no results” confusion.
Q5What is the difference between the Thread Group loop count and a Loop Controller?
The Thread Group loop count repeats everything under the group. A Loop Controller repeats only the steps inside it. When nested, the counts multiply.
Q6How do I make a login happen only once per user?
Place the login under a Once Only Controller, or use a Loop Controller design around the repeated steps. Also make sure the session is kept between loops by checking “Same user on each iteration.”
Q7Why did my timed test end before the duration?
Probably because a finite Loop Count finished first. For timed tests, tick Infinite and let the duration end the threads.
Q8How many rows of test data do I need?
If each iteration uses one row and all threads share the file, you need threads times Loop Count rows, plus a margin. Decide on purpose whether to recycle the data or stop threads at the end of the file.
Q9How can I run exactly one thousand iterations when threads do not divide it evenly?
Use a Throughput Controller in total executions mode, or let a data file with exactly one thousand rows stop the threads at its end.
Q10Does the ramp-up change how many loops each thread does?
No. Ramp-up only changes when threads begin. Every thread still performs the full Loop Count, so a long ramp-up simply makes the test last longer.
Q11How does Loop Count behave in distributed mode?
Each worker runs the full Thread Group with its own Loop Count. The server sees the sum of all workers, so divide threads or loops by the number of workers when planning totals.
Q12How do I stop an infinite test cleanly?
Use a duration, or send a shutdown to a non-GUI run so running requests finish. An immediate stop interrupts requests and can distort the last numbers.
Q13Can the Loop Count come from a variable or property?
Yes. You can supply it from a named property at start-up, so the same test file can run small or large. Loop Controllers also accept expressions in many versions, so check your version’s documentation.
Q14Is a higher Loop Count always better?
No. Too few loops show only cold-start behaviour, but too many waste time and fill result files. Choose a count that covers warm-up, a stable period, and the question you are trying to answer.
Q15Why do requests per second drop when the server slows down in a fixed-loop test?
Because each thread waits for its answer before it can start the next request. Slower answers mean fewer requests per second. If you need a steady rate, add pacing or a throughput-based timer, or use an open-model style group.

38Summary and Key Takeaways

The whole guide in a few lines.

Remember These Points

  • The Loop Count is how many times each thread repeats its full set of steps. Total iterations equal threads multiplied by Loop Count.
  • Total requests equal threads x loops x requests per iteration. Calculate it before you run, and compare it with the report afterwards.
  • Use a finite count for a fixed amount of work, and Infinite with a duration for a steady load over a fixed time. Never leave Infinite without a way to stop.
  • The Thread Group loop repeats the whole journey, and a Loop Controller repeats only part of it. Nested loops multiply.
  • Keep one-time steps such as login in a Once Only Controller, and choose “Same user on each iteration” based on what one loop represents in real life.
  • Prepare threads times loops rows of test data, and decide on purpose what happens at the end of a file. In distributed mode, every worker repeats the full plan.
  • Run long loops in non-GUI mode with light listeners, watch the active threads graph, compare early and late loops, and test only systems you are allowed to test.