Cached variable

I have vus=40, so I assume in default loop I will get 40 requests if I cache the groupid.
(it is fixed here)

    for(let i=0; i<testenvs.length; i++) {
        for(let j=0; j<verticals.length; j++) {

            // accesstoken from keycloak
            let accessToken = actoken(testenvs[i], verticals[j]);
            //console.log(`testenv=${testenvs[i]}, vertical=${verticals[j]}, accesstoken=${accessToken}`);


            // tricky with cache
            if(!(testenvs[i] in cache)) {
              cache[testenvs[i]] = {};
            }
            if(!(verticals[j] in cache[testenvs[i]])) {
              cache[testenvs[i]][verticals[j]] = groupget(testenvs[i], verticals[j], accessToken, "performancetestgroup");
            }
            let groupid = cache[testenvs[i]][verticals[j]];

But why do they show up at the end?
(The patch group operation afterwards uses this value)

Hi @mortenb123, Sorry for the slow reply :frowning:

I don’t think I am getting what you are asking or even what the observed problem is.

Some comments:

I have vus=40, so I assume in default loop I will get 40 requests if I cache the groupid.

There are no (HTTP) requests or groups in the code you provided. It will be really hard to guess how you will use them without even some sanitized code.

If you have 40 VUs and you are talking about cached VUs - I need to tell you that VUs are completely separate and do not share any of their variables. So you can not have a cache between them. I feel that this usually trips most people. For a more detailed example you can look here.

From the rest of the comments I can’t be certain if the code you provided underneath makes http requests or if it is only used later.

That graph shows 1 and then like ~20s later a bunch more requests, is this correct? I can see how depending on what and how you make the requests or even what output you are using, this might act differently.

Also, the time of the event is when the sample is emitted (so the end of the request). With this particular response times this might not change a lot more when they were actually started. But looking at it there are good chances they were started exactly at the same time.

This might mean that the first request is not the same as the rest and instead is something done in setup

But unfortunately based on this information I can’t really tell you much :(.

Please try to re-explain your problem and what you are doing in more detail.