Вопрос

I don't clearly understand what is the meaning of a "Thread group" in JMeter. Does that means all the tests (Java requests etc) belong to a certain thread group run in a one thread or each test in that thread group runs in a separate thread? I couldn't get a clear understanding about this from JMeter documentations or googling.

Это было полезно?

Решение

For explanation see:

A thread group is a set of threads executing the same scenario. Set the number of iterations in the configuration. Thread behaviour is defined according to ramp up and destroyed once the number of iterations per thread has elapsed.

Note that from version 2.8, you will be able to delay thread creation until the time the thread must start working, this will be adapted to tests that use very short lived threads and many threads.

Thread groups can be seen as a set of Virtual Users but not necessarily. It can be something else depending on how you develop your test.

Другие советы

As I understood (What I wanted to know), All the operations in a JMeter thread group run sequentially once per each thread and iteration. So it means each of operations in a thread group does not run in its own separate set of threads, but it shared each thread with the other operations in its thread group.

For example,

  • Thread Group 1
    • Operation 1
    • Operation 2
    • Operation 3

If we have scheduled this thread group Thread Group 1 to run in 3 threads, what happens is,

  • Operation 1, Operation 2, and Operation 3 will execute in thread 1.
  • Operation 1, Operation 2, and Operation 3 will execute in thread 2.
  • Operation 1, Operation 2, and Operation 3 will execute in thread 3. etc

Previously I was not sure whether each of these operations run on its own separate thread.

Thread = simulated user.
So thread group = users.
Check out jMeter Plugins thread group controllers with far more control than default thread group.

Just to further contribute following my own investigation (for clarity and completeness I hope):

  1. A ThreadGroup has requests/ "operations" as described above (in Manjula Weerasinge's summary) but also has users and loops config.
  2. A ThreadGroup creates a thread per user. This thread (representing a user) runs all operations in that ThreadGroup, in sequence in that loop.
  3. These threads are re-used across all loops - that is: loop 2 will also execute the same set of operations as n different users but this will reuse the same threads as loop 1.

In summary, a ThreadGroup has a thread per user and and it's used to run all tests in that group, for all loops.

This was true across two loops with 10 users where my test contained the following:

System.out.println("MyTest#testSearchNodeByNodeNameExactMatch: MyTest=" 
        +this + "(" +System.identityHashCode(this)  +")" 
        +", thread=" +System.identityHashCode(Thread.currentThread()));

And the logs could be summarised using (assuming println output written to thread-output.2.txt):

grep MyTest#test thread-output.2.txt | awk -F ', ' '{print $2}' | sort | uniq
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top