Search code examples
jmeterjmeter-plugins

Active Threads Over Time vs. number of threads (users)


I've got the following Thread Group description with 120 Users, a Ramp up time of 60 Seconds and the test should run (additionally?) 120 Seconds.

ThreadGroup

After running the test, I wanted to see my active threads over time. I would expect to have 120 threads after 60 seconds. However I get the following graph:

Active threads Over Time

What did I misunderstand?


Solution

  • We need to keep all threads busy during the test by setting <intProp name="LoopController.loops">-1</intProp>

    Complete ThreadGroup with ramp_time = 20

          <ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group" enabled="true">
            <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
            <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
              <boolProp name="LoopController.continue_forever">false</boolProp>
              <intProp name="LoopController.loops">-1</intProp>
            </elementProp>
            <stringProp name="ThreadGroup.num_threads">120</stringProp>
            <stringProp name="ThreadGroup.ramp_time">20</stringProp>
            <boolProp name="ThreadGroup.scheduler">true</boolProp>
            <stringProp name="ThreadGroup.duration">120</stringProp>
            <stringProp name="ThreadGroup.delay">1</stringProp>
            <boolProp name="ThreadGroup.same_user_on_next_iteration">true</boolProp>
            <boolProp name="ThreadGroup.delayedStart">true</boolProp>
          </ThreadGroup>
    

    Example output when running test in non-GUI mode, which is recommended: jmeter -n -t testplan.jmx -l results.jtl. As we see, after rampup, all 120 threads are busy.

    Creating summariser <summary>
    Created the tree successfully using testplan.jmx
    Starting standalone test @ 2025 Jan 19 11:43:26 CET (1737283406619)
    Waiting for possible Shutdown/StopTestNow/HeapDump/ThreadDump message on port 4445
    summary +      1 in 00:00:04 =    0.2/s Avg:   239 Min:   239 Max:   239 Err:     0 (0.00%) Active: 20 Started: 20 Finished: 0
    summary +    822 in 00:00:29 =   28.2/s Avg:    18 Min:     8 Max:   252 Err:     0 (0.00%) Active: 120 Started: 120 Finished: 0
    summary =    823 in 00:00:33 =   24.7/s Avg:    19 Min:     8 Max:   252 Err:     0 (0.00%)
    summary +   1171 in 00:00:30 =   39.1/s Avg:    23 Min:     5 Max:   853 Err:   237 (20.24%) Active: 120 Started: 120 Finished: 0
    summary =   1994 in 00:01:03 =   31.5/s Avg:    21 Min:     5 Max:   853 Err:   237 (11.89%)
    summary +   1186 in 00:00:30 =   39.5/s Avg:    14 Min:     3 Max:    68 Err:   169 (14.25%) Active: 120 Started: 120 Finished: 0
    summary =   3180 in 00:01:33 =   34.0/s Avg:    19 Min:     3 Max:   853 Err:   406 (12.77%)
    summary +   1114 in 00:00:28 =   40.4/s Avg:    13 Min:     4 Max:    80 Err:   121 (10.86%) Active: 0 Started: 120 Finished: 120
    summary =   4294 in 00:02:01 =   35.5/s Avg:    17 Min:     3 Max:   853 Err:   527 (12.27%)
    Tidying up ...    @ 2025 Jan 19 11:45:27 CET (1737283527656)
    ... end of run
    

    When running test with e.g. <intProp name="LoopController.loops">1</intProp>, each thread will quit after 1 sample.