skip to content

In JMeter, what separates a Sampler from a Logic Controller when the manual calls both controllers?

level: middleimportance: should knowfreq 54%

answer

  1. The manual calls both of them controllers
  2. Only one of them talks to a server
  3. One decides, the other delivers
  4. One controller breaks the rule deliberately

basics

~20 s

A Sampler sends a request and produces a sample result. A Logic Controller sends nothing; it decides which of its children run and how often. Both are controllers in JMeter's vocabulary, which is why the distinction gets asked.

solid answer

~50 s

JMeter's manual says it has two types of controller: **Samplers**, which tell JMeter to send a request to a server and wait for a response, and **Logic Controllers**, which "determine the order in which Samplers are processed". A sampler is the only family that produces traffic, so it is also the only family that produces the sample result assertions, post-processors and listeners consume. A logic controller produces nothing of its own — a Simple Controller literally provides no functionality beyond grouping, and an Interleave Controller merely passes on one child per pass. The documented exception is the **Transaction Controller**, which generates an additional sample measuring the overall time of its nested elements, either as a sibling or as a parent of them. Knowing that exception is the difference between having read the reference and having guessed.

go deeper

for a junior

Learn the one-line split: samplers send requests, logic controllers decide which samplers run. Being able to point at a node in a tree and say which of the two it is already answers the screening version of this question.

for a middle

Explain the consequence, not just the label. Only samplers produce a sample result, so assertions, post-processors and result-file rows all hang off samplers; controllers change counts and ordering instead.

for a senior

Name the Transaction Controller exception and what its generated sample measures, including that it is successful only if every sub-sample succeeded. That is the detail that separates read-the-reference from guessed-it.

for a principal

Set expectations about how plans are shaped. Decide whether transactions are the unit your reports are read at, because that choice determines which controllers teams are expected to wrap their samplers in.

## Two families, one word JMeter's own vocabulary is the source of the confusion. The user manual says plainly: "JMeter has two types of Controllers: Samplers and Logical Controllers. These drive the processing of a test." The GUI then splits them into two Add-menu categories, **Sampler** and **Logic Controller**, and the Java layer gives them separate interfaces — `org.apache.jmeter.samplers.Sampler` and `org.apache.jmeter.control.Controller`. So when a candidate says "the controllers in this plan", the interviewer genuinely cannot tell which family is meant, and the follow-up is exactly this question. ## What each one does | | Sampler | Logic Controller | | --- | --- | --- | | Talks to a server | Yes — this is its whole job | No | | Produces a sample result | Yes, one per execution | No, with one documented exception | | Typical members | HTTP Request, JDBC Request, JMS request, FTP Request, OS Process request, Debug Sampler | Loop, Once Only, Interleave, Random, If, While, Switch, ForEach, Throughput, Runtime, Transaction, Module, Include, Critical Section, Recording, Simple | | What it changes | The traffic itself | Which children run, and how many times | The manual's framing is worth memorising: "Logic Controllers let you customize the logic that JMeter uses to decide *when* to send requests. Logic Controllers can change the order of requests coming from their child elements." A few members make the boundary vivid: - **Simple Controller** — the reference says it "provides no functionality beyond that of a storage device". It exists to group nodes in the tree and nothing else. - **Once Only Controller** — processes its children only once per *thread*, and always on the first iteration of any looping parent. - **Interleave Controller** — passes on one child request each pass, remembering its place rather than choosing at random. - **Critical Section Controller** — takes a named lock so only one thread executes its children at a time. None of those sends a request. They each change which sampler runs next. ## The exception you must be able to name The **Transaction Controller** is the one logic controller that emits a sample of its own. The reference: it "generates an additional sample which measures the overall time taken to perform the nested test elements". Two modes exist — the extra sample is added after the nested samples, or as their parent — and the generated sample is only successful if all of its sub-samples were successful. By default the measured time excludes timers and pre/post-processor time unless *Include duration of timer and pre-post processors in generated sample* is ticked. That single element is why the blanket claim "controllers never produce samples" is wrong, and why an interviewer often follows up with it. ## Why the distinction is load-bearing Once you can classify a node correctly, several things follow without further reading: 1. **Only samplers can be the subject of an assertion or a post-processor**, because those families need a sample result to work on. 2. **Only samplers appear as rows in a result file**, apart from the transaction samples a Transaction Controller adds. 3. **Adding a logic controller changes counts, not traffic shape per request** — wrapping five samplers in a Loop Controller multiplies executions; it does not alter what each request looks like. 4. **A plan with no sampler does nothing at all**, however many controllers it holds, which is why the manual's minimal plan is Test Plan plus Thread Group plus one or more samplers. ## Answering it cleanly A strong answer is three sentences: samplers are the family that talks to the system under test and produces results; logic controllers are the family that decides which samplers run and how often, and produce nothing themselves; the Transaction Controller is the documented exception that emits an extra sample around its children. Then stop — the individual controllers' semantics are a different conversation.

  • Name a Logic Controller that does produce a sample, and say what it measures.
    The Transaction Controller. It generates an additional sample measuring the overall time taken by its nested elements, either alongside them or as their parent. The generated sample counts as successful only if every sub-sample succeeded, and by default it excludes timer and pre/post-processor time.
  • Why can you not attach a Response Assertion so that it judges a Loop Controller?
    An assertion needs a sample result to inspect, and a Loop Controller produces none — it only decides how many times its children run. Attached above a controller, the assertion applies to the samplers beneath it instead, judging each of their responses.
  • What does a Simple Controller contribute to a plan?
    Grouping, and nothing else. The component reference says it provides no functionality beyond that of a storage device. It is useful for tidying a tree and for bounding the scope of a hierarchical element such as an assertion, but it never changes the order or number of executions.

saying these in an interview costs you the question

  • Saying Logic Controllers send requests to the server
  • Claiming no controller ever produces a sample of its own
  • Thinking a Simple Controller changes execution in some way
  • Using controller as a synonym for logic controller
  • Expecting a plan of controllers with no sampler to generate load