How to get average session duration and use it for getting the number of VUs

Hi, newbie here!

I am not sure how to begin setting up my test (ex. Getting the number of VUs and its computation, how to indicate it in the load ramping executor, etc.)


The client has 50k users wherein 15k of it are Admins while the rest are Staffs. I will only be needing the 15k Admins for my test. But as per requirement, I will only be using 20% of that 15k. So I will be needing to perform a load test for a specific web transactions/scenarios for the 3k Admins only.

Example website transaction/scenario to load test is Workspace Selection (selecting a workspace). But note that on my js script, I included the endpoint requests for the Log in and Log out Scenario. So basically, to simulate a somewhat real user behavior, the scenarios in my single js script will include Log in → Go to Workspace Tab → Workspace Selection → Log Out. I also placed each covered API requests of these scenarios in a GROUP (total of 4 groups inside my script). As per requirement, I need to load test only the Workspace Selection scenario. The load test execution duration is 5 minutes.

  • I am using this formula: Number of VUS= (#OfSessionsInAMinute * AverageSessionDuration) / 60s

    #OfSessionsInAMinute = number of sessions in a minute
    AverageSessionDuration = how long each session in its duration in seconds


QUESTION # 1: How to get the AverageSessionDuration of Workspace Selection scenario?

  • What I did is that I ran the script using per vu iteration executor with 1VU and 3k iterations (since I am testing 3k Admins performing the scenario). So that will allow me to get the average response time or average duration of that specific scenario. I believe there are two methods to know the average response time:

a) I placed a tags for each API requests that is covered in that specific scenario I am testing and
declared it in my threshold which will look like http_req_duration{type:API}. From there, I will then
check the avg value of it in the displayed local execution results.

b) Since I placed it also in a group, I can get the group_duration which will look like 'group_duration{group:::Workspace Selection}' and declared it also in my threshold. From there, I will then check the avg value of it in the displayed local execution results.

Am I doing it correctly? And what method should I use, a or b? The value of which is what I will be using in computing the number of VUs formula (AverageSessionDuration)

QUESTION #2: How to get the Number of VUs and apply it on my test.

  • Let’s say I already have my AverageSessionDuration (ex. Workspace Selection scenario took 3s) , so this will give me

Number of VUs= (3000 sessions * 3s) / 60s = 150 VUs

So on my modified script for the actual load test execution…will it look like:

scenarios: {
      Main: {
        executor: 'ramping-vus',
        stages: [
          { target: 150, duration: '1m' },
          { target: 150, duration: '3m' },
          { target: 0, duration: '1m' },

        exec: 'main',

Are my computation and how I applied it on the set up of stages were correct?

Thank you so much.

Hola @mat !
You have a lengthy situation here but I will try to answer some parts of it.
Modeling scenarios is tricky, but I like to start having some data first.

  1. Number of users test (seems like you already have it, must be defined by the project or targets)
  2. List of business processes (for now you only have Workspace Selection)
  3. Expected or targeted utilization per process per hour (it seems this is the one you are missing and refering to as #OfSessionsInAMinute)

It sounds to me like you are trying to figure out point #3 from what the script does.
That parameter should come from the goals of the load test, or from utilization metrics in production.
You already know you have 3k Admins (virtual users) but not how much do they all hit or trigger “Workspace Selection”.

It is NOT recommended to define those from a script. That must be provided by the business. Either from utilization metrics in production or expected projections.

So for now, let’s say they tell you that on average WorkspaceSelection is triggered 150k times per hour.
That gives you:
Virtual Users: 3000
Actions x hour: 150000

Very similar to the formula you stated, we can check how many times each virtual user has to iterate in an hour to hit the load you are trying by dividing:
Each vUser has to iterate 50 times per hour in this example. More or less 1 per minute.
That means that if your total duration of the test is 5 minutes, you will have about 5 iterations per VU.

Then I would do the scenario something like this:

scenarios: {
Main: {
executor: ‘per-vu-iterations’,
vus: 3000,//You mentioned you need those 3k
iterations: 5, //In 5 minutes
maxDuration: ‘5m’,
exec: ‘main’,

But as I mentioned, it is key that you receive that from the business.

I have a post here that also may help:

Hope this helps. And if I misunderstood let me know and we can follow up.