Hey @syedrakeentest11,
I’d like to apologize in advance as I cannot share the complete code due to privacy and confidentiality concerns. However, I’m happy to share relevant snippets and clarify my doubts, which I hope will be helpful.
Sure, I’m always happy to help, or try to hehe. Don’t worry about privacy and confidentiality concerns, that’s completely understandable and common.
So, let me try to reply you to each topic discussed on this thread:
1. Confusion between constant per VU iterations and constant VUs over a duration
Here, the difference between both options is that:
- Option 1: Performs 50 operations (your function), distributed across 50 virtual users.
- Option 2: 50 virtual users are performing operations (running your function) during one minute.
So, if the operation would take exactly one minute, then both would be equivalent, but if not, which I think it’s the case, in the second one you’re doing way more than 50 operations.
By looking at your requirements, I think what you’re looking for is Option 1, because that’s what “simulates” the scenario where 50 virtual users perform a operation (e.g. log into a web site).
However, you need to be aware that this is not equivalent to having 50 RPS, because in a realistic environment, when you have 50 users logging into, there’s network delays, human input, etc, etc, and if the operation just takes some ms or a couple of seconds, then there’s no point in time where all the 50 users are doing the operation at exactly the same second.
If you want to achieve a certain rate of RPS, you’ll likely need to explore a different executor, like constant-arrival-rate
. But again, I think that looking at your requirements, the Option 1 is likely enough, as it is what’s likely to represent 50 virtual users doing the operation/steps you have in your test function, more realistically.
2. Using JSON for dynamic tokens
- Does the size of the JSON or using dynamic tokens impact the metrics significantly?
- Should I instead use the same token for all VUs to simplify the setup, or is using unique tokens better for accurate results?
Here, I assume you’re only using the JSON “locally”, and that each VU just picks one of the values to send it over HTTP (or whatever transport is used for auth). If that’s the case, I cannot see how that could impact the metrics, it should be fine. Unless having dynamic tokens have any implication for your backend, but not from the k6’s perspective.
Regarding the JSON file size, I’d recommend you to use SharedArray
if you’re not doing so yet. But that’s only to keep k6 memory allocations low, nothing that really impacts the metrics of your test.
In any case, 8KBs over 50 VUs shouldn’t be a problem at all. The problem is when you have a larger file, let’s say 5MB, plus a larger amount of VUs, let’s say 10K, because in that case, if you don’t manage memory efficiently, k6 could be allocating those 5MBs up to 10K times, which would be ~50GBs, unlikely to fit a normal laptop memory.
In conclusion, always try to use SharedArray
to avoid issues, but in your case, with the rough numbers you shared, you don’t need to care much.
3. Different P95 responses
- How should I interpret these differences?
- Which method is better for the given requirement, and what should I conclude about the performance?
I think I replied to this one above already, but let me try to explain it with further details, and see if that helps you a bit more.
Let’s suppose that what your main test function (export default function { ...}
) is to simulate that a user goes to a site, like: mycompany.com/login
, types user and password, and clicks on login
.
- The Option 1, would be the equivalent of having 50 users doing that operation at a start signal. So, even if they’re all doing the same operation at the same time, the peak of
POST /login
HTTP requests won’t be 50, because there are different factors that would distribute the load a bit. For instance:
- Some will take a few seconds to type the user and password, while for some others which are slower typing will take a few more seconds, so not all the 50 users will hit the
login
button at exactly the same second.
- Some will have a worse network, so it will take a couple of seconds more for them to load the login page, and so they won’t hit the
login
button at exactly the same second as those users who have a faster network.
- The Option 2, would be equivalent of having 50 users doing that operation, since a start signal, and during a minute. So, once a user have logged in, let’s say in 5 seconds, they would start the process again: navigate to login page, type the credentials and click on the
login
button. Repeatedly, over a minute.
- That’s why here, the peak of RPS in this case is much higher, because the delay caused by the aforementioned reasons would make some users to be performing the operation at the same second, although maybe those that are faster will be on their 5th iteration, while for others it could be their 3rd iteration.
Regarding how to interpret results, and what approach is better:
- The difference of
p95
response times clearly indicates that your system is capable to handle the load of 50 virtual users doing an operation one time, but not (well, yes but poorly) when 50 virtual users are doing the same operation over and over for a minute. Otherwise, if the system would be able to handle both scenarios successfully, the p95
response time would be almost the same in both cases, despite of the load.
- If I’d be expecting up to 50 users logging in the same date at the same time (let’s say I launch a promo campaign in my online store), I think I’d just go with Option 1. But it really depends on the use case and what are your expectations.
- Note that “business requirements”, like the aforementioned example with 50 users logging into my online store, are “different” from technical requirements, like, let’s say someone asks to: support 50 clients consuming an HTTP API in parallel (50 RPS). In such case, I’d suggest another execution, as I suggested above.
If any part of my query is unclear, please let me know, and I’ll be happy to provide more details or share additional code snippets if possible.
I think everything is more or less clear. Although, as you can see, I need to guess estimate what your test function is doing, and what kind of requirements do you have. I tried to mention multiple examples, so it helps you idependently of your concrete scenario.
I hope that helps, but if not, just feel free to bring back your remaining doubts again! 