duration in jmeter thread group

15.6k Views Asked by At

duration in thread group

what is the meaning of the duration in jmeter thread group.

I found this is official document saying that is end time while the startup delay is the start time.

But is it the end time since we start executing the test? or since the thread is created?

first timestamp

thread-50

When I set the 50 threads and duration 1s, the first timestamp in the output file is 1607391972250 (2020-12-08 09:46:12.25), the thread-50 only send HTTP Request 1 in timestamp 1607391973232 (2020-12-08 09:46:13.232). So it cannot be the end time since each thread is created

But when I set 1000 threads, the timestamp of the last several thread will exceed 1s than the timestamp of first thread's first request. it cannot be the end time since the we start executing the test

So what is the real meaning of the duration?

2

There are 2 best solutions below

0
On

As per Thread Group documentation:

  • Specify Thread lifetime If selected, confines Thread operation time to the given bounds

  • Duration (seconds) If the scheduler checkbox is selected, one can choose a relative end time. JMeter will use this to calculate the End Time.

So "Duration" limits the maximum duration of a given single thread, JMeter starts threads within the bounds of the Ramp-Up period.

In your case you have Ramp-Up time set to 1 second and Duration set to 1 second, it means that JMeter will start 50 threads in 1 second (so the last one will be started in 1 second after test start) and then the last thread will be terminated in another 1 second so its total lifetime plus the time required to execute the first sampler if its response time is more than 1 second

You may find Custom Thread Groups easier to use, all of them provide easy configurable visual way of defining the workload, you can install them using JMeter Plugins Manager

enter image description here

0
On

Duration is neither the start time nor the end time but the timespan between the two. If your total duration is 1 second and your ramp up time is 1 second it might lead to a bit confusion since some of the threads have only just started when the whole test is already over. The duration starts counting when you either hit the "play button" in the GUI or start the test via command line. Startup delay will mostly make sense if you have several thread groups inside your test plan and want some part of the virtual users to start at a later point for either logical reasons (e.g. thread group A generates forum posts and group B starts searching those forum posts after 1 minute) or for some kind of load shaping (might be achievable within one thread group though). This is relative to the test start.

Anyway JMeter is a tool mostly used for load and performance testing. In this type of testing you will usually have the tests run for minutes or hours. So from my perspective your question is mostly theoretical unless you want to achieve something very specific which you did not further elaborate.