1

I am looking into JMeter and trying to understand the concepts. Especially confusing to me is the Threads vs Controllers.
I understand that a Thread represents a User and a Controller is a container for Samplers and determines their execution.
But what is the relation of a Thread and a Controller? Does a thread execute all the controllers that are children of the Thread Group?
So a thread (to simplify) calls each controller which in turn fires the samples?
But for example what is the difference between specifying a loop count of 20 in my Thread Group and using a While Controller to fire requests for 20 times?
Any help clear this out?

Cratylus
  • 52,998
  • 69
  • 209
  • 339

2 Answers2

1

You understand well, a Thread represents a User and a Controller is a container for Samplers and determines their execution.

Yes it does execute or not (if controller is inside IfController) all controllers that are children.

Yes a thread (to simplify) calls each controller which in turn fires the samples.

But for example what is the difference between specifying a loop count of 20 in my Thread Group and using a While Controller to fire requests for 20 times? It is very simular, many people add a WhileController while just setting loop count is enough.

You usually need a While controller if you want to repeat a set of samples inside main iteration.

Read JMeter Component Reference and Elements of a Test Plan

Read also Scoping Rules to understand how config elements apply.

UBIK LOAD PACK
  • 33,980
  • 5
  • 71
  • 116
  • I noticed that on right click I have the same options for all nested elements.So for example if I have a container `A` and add as a child a CSV element and then to `B` container which is a child of A also add a CSV as a child, which CSV will the thread use in the run? – Cratylus Nov 20 '12 at 21:24
  • I edited answer. But if it's not clear then describe your structure with a screenshot and I will try to answer – UBIK LOAD PACK Nov 20 '12 at 21:31
  • So for example if I want to represent a transaction with the server, all these `X` number of requests should be grouped under the same controller?So a controller correlates requests?Additionally each thread goes over each controller that has as children one by one and in order? – Cratylus Nov 21 '12 at 20:42
  • You can use one or more TransactionController to organize your requests as you want them to be reported. A controller contains requests (what do you mean by correlates ?). Yes Thread goes sequentially over each Controller of ThreadGroup, but it executes samplers inside this Controller depending on the implementation of Controller (one of the samplers, all samplers, interleave ....) – UBIK LOAD PACK Nov 21 '12 at 20:45
  • By correlate I mean the following:That if for example `Req-1`, `Req-2`, `Req-3` and `Req-4` form in my server a transaction and I am interested to send these requests as a transactions (i.e. not just fire requests) they should be under the same controller?So the controller essentially forms my transaction? – Cratylus Nov 21 '12 at 20:51
  • If by send as a transaction, you mean Search transaction is composed of autocomplete request + search request then yes , you should put them in a TransactionController. But you can also put in a LoopController 2 TransactionControllers – UBIK LOAD PACK Nov 21 '12 at 22:03
  • One last question.If for example I have 4 requests that form a single "entity" e.g. a transaction to my server and I want to know if this set is finished within `X` seconds is this a configuration of the controller or thread? – Cratylus Nov 21 '12 at 22:34
  • What do you mean by entity ? Is this entity a main page + ajax queries ? Or embedded resources to download? If it's not ajax andIf you want to have response time of the 4 calls , TransactionController will do that, if you want to consider the transaction in error if it exceeds some time, use DurationAssertion. – UBIK LOAD PACK Nov 21 '12 at 22:43
  • Any news ? Are my response ok, if yes you should accept it so that it's helpful to others – UBIK LOAD PACK Nov 22 '12 at 20:43
1

Its simply like in Java. Thread means an execution thread, controllers are standing for control structures. So if you want to decide how much stress do you put on your tested application the main thing is the number of threads. Each thread executes its children in order. If you want to test the same thing more than once, for controller is your mate, if you want to do this parallel, you need threads (threadgroup with a given number of threads).


One main difference, which you need to understand, comes in picture when you want to parametrize your test.

So for example you have a web application and you have 100 demo users. Each user can log in only once. This case you need something, that tells to your test threads, which user should they use. This is usually a CVS Data Set, which can be used in a way, that threads can fetch one row for themselves, and they use that. You can say as well, that when there is no more row in the CSV, your test should stop. The same concept (giving one data for each iteration in a for loop) is harder to implement with a for loop, or other controller.

Gábor Lipták
  • 9,646
  • 2
  • 59
  • 113
  • So a controller basically captures a flow/transaction?I.e. all children of a controller can be considered as related? And each thread goes over the controllers one by one in order? – Cratylus Nov 21 '12 at 20:40
  • Yes, a thread goes over the controllers one by one. If it is finished, it either starts again (depending on iterations set in threadgroup) or stops. What you see top right part next to the green field is the counter of living threads. What controllers do is described in their docs, but in general they define some flow for their subcomponents. For example "For" iterates all of its children ones or more. But "Random" picks one child at each run. Once-only controller calls its children only once during the life of its enclosing thread. So Thread is a processing unit, controllers are flow control. – Gábor Lipták Nov 21 '12 at 22:09