want to control number of vus using k6 status how can I do it.
To control the number of VUs during test execution you would use the
k6 scale command, not
See this article for details.
How do i know the port k6 selects for running other scripts?
If you don’t specify
--address, k6 will try to listen on the default
localhost:6565, and if that fails, e.g. because the port is already used by another process, you will see the message:
WARN Error from API server error="listen tcp 127.0.0.1:6565: bind: address already in use"
…and that k6 instance will not be accessible via the HTTP API.
So there is no fallback mechanism for trying other ports; the server simply won’t start.
You could technically specify
--address localhost:0, in which case the OS will assign the next freely available port at random and the server will start for all processes, but that would make your task of finding the assigned ports even more difficult. Plus you say that you can’t use
k6 run --address, so this won’t be of any help, I suppose.
ps: I cannot specify the port in kr run command.
May I ask why?
k6 run --address is the only way to control which API port is assigned, and it’s meant for use cases like yours.
Perhaps k6 could output the address it started the API server on if run with
--verbose, but I don’t think that would help much in your case since there is no port fallback and you’re not able to specify
-a localhost:0 beforehand.