-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Websocket loop executing only once. #663
Comments
The problem is that I'll leave this issue open, since I feel like this misunderstanding is common enough to indicate we don't communicate this clearly enough. Improving the documentation and CLI help would probably help with ameliorating it, but we should probably also emit a warning if users specify a number of iterations that's less than the number of VUs. |
Got it. If Is this a proper way to handle a situation where the connection should be closed only after socket.setInterval(function timeout() {
if (myCounter >= n) {
socket.close()
}
}, 1000); |
I wouldn't say it's guaranteed. If you have a very, very short |
I noticed that happening yesterday, after adding a bunch of
Is there a reason for this approach / behavior? Or is it something that is to be changed in the future? |
The reason for the current approach is that k6 is primarily a load-testing tool and usually there's no reason for VUs to sit idle when there's work to be done. When there is, you can explicitly add slack with I think that generally it shouldn't matter all that much which VU executes a script iteration, even if you don't use k6 only for simple load testing. If you have a complicated scenario/use case or want do also have some functional testing, using the |
A part of the test is for a custom publisher-subscriber messaging broker (similar to Apache Kafka, PubNub, Pusher). A simple test case would be having 10 users and 10 channels. Each user would publish a message to each channel 10 times. So there would be 1000 messages being sent, and 10,000 messages being received (the publisher would receive the published message as well - optional). This relates to my previous question - VU should stop executing only after it has received 1000 messages. Before the message transactions start, there are a few other operations which would help the server uniquely identify each connected client. Ignoring the numbers, here I would need each VU to handle its own and not steal other messages. |
It seems like you shouldn't have any issues if you run with |
I got a couple of steals with this on some random test runs. There are some other small tests also which would require the VUs to not steal tasks. Majority of my tests require a specific number of VUs to be connected to the server and running simultaneously. I saw the link you shared about if (__ITER !== 0) {
return
} It would mean that the VU started another iteration, i.e. stole a task. But because it has already iterated once, it would exit. It wouldn't put the task back for another VU to handle it. Correct? |
But that's just what VUs are. The
Yes, once the
That's kind of the purpose of the But if you actually need that much precision, maybe you'd benefit a lot more from |
I really appreciate you trying to help me. We came up with a way to handle it. Just for testing purposes, we changed the code a bit so that the server sends a message at the end singaling the client to disconnect. Then it worked the way we wanted it to. k6 has been extremely useful. If you're open to feature requests, I would request for a flag to have each VU run only a single iteration. Something like Thanks a lot for your time. |
Thanks, we're quite open to feature requests and your use case is a valuable data point 😄 We previously considered adding |
Makes sense. That would be a really useful feature though. Thanks again 😄 |
Combined with mentions in the readme, docs and CLI help this should be enough to prevent confusion, so we can close #663
I'm trying to load test a websocket server. But for some reason, the
vus
doesn't affect the test at all. I'm not sure if this is a bug. I may have misunderstood the docs. Or my test script may be wrong.Here's a simple echo server program to explain what's going wrong. The server would echo back the same message 10 times.
Here's my server code in Go.
And here's my test script
There are 10 users. So I expected to see
ws_msgs_sent
= 10. Theconsole.log("Message received: ", data);
part of the test script doesn't come up in the output. And also there isn't anyws_msgs_received
in the output. I would appreciate a correction if I'm doing it wrong.The text was updated successfully, but these errors were encountered: