Resource requirements for browser tests

My k6 browser tests are working well for a small number of VUs (5 or so) but they are using excessive CPU + memory and throwing go errors when I increase the VUs to 20 or more.

Is the intent of the browser tests purely to allow browser performance to be observed while protocol tests are run, or can browser tests be used independently to put actual load on the servers?
If the latter, is there any guidance available for determining the resource needs for running browser tests? Or best practice recommendations to minimize resource usage for browser tests?

Hi @dnise01,

Thank you for your insightful questions.

My k6 browser tests are working well for a small number of VUs (5 or so) but they are using excessive CPU + memory and throwing go errors when I increase the VUs to 20 or more.

Could you please provide us with more information about your hardware configuration, script, and output?

Is the intent of the browser tests purely to allow browser performance to be observed while protocol tests are run, or can browser tests be used independently to put actual load on the servers?

Browser tests can serve both purposes, but they are not yet optimized for load testing. At present, the best approach is to use them as functional tests.

If the latter, is there any guidance available for determining the resource needs for running browser tests? Or best practice recommendations to minimize resource usage for browser tests?

The recommended best practice is to launch a single browser instance rather than multiple browsers, as running multiple browsers can place an enormous strain on your system resources.

Thanks!

Thanks for your response, @inanc . We were hoping to use xk6-browser for load testing but based on your response I now understand that is not a good approach at this time. I’ve been impressed by how quickly your product is evolving and will continue to follow k6’s progress and keep it in mind for this and other use cases.

RE: hardware configuration, script and output. Sharing this in case it is useful to you, but I’ll be setting this poc aside for now so there is no need to research this on my account.
I was running the xk6-browser v0.8.0 directly on my windows dev machine (2.5mhz,8cores,64GB RAM) and also tested running via the recommended docker container on my dev machine. Since it was not an isolated environment, not all resources were available for the tests - task monitor showed ram over 3GB and cpu over 80% consumed by xk6-browser and associated browser instances. Overall cpu spiked to 100% during the tests and errors seemed to correspond with the cpu spikes

My script picks a random user from a shared array, opens a browser & page, logs in and navigates to a few different routes, clicks links, waits for networkidle and checks for expected results, and then closes the browser and page in the finally block. I tried to follow the latest xk6-browser async examples closely. I also added some random waits and a browser slomo setting to see if they would help.

At higher loads I was seeing exceptions like these:

ERRO[0031] communicating with browser: read tcp 127.0.0.1:50315->127.0.0.1:50314: wsarecv: An existing connection was forcibly closed by the remote host.  category=cdp elapsed="0 ms" goroutine=352
ERRO[0031] process with PID 23636 unexpectedly ended: exit status 1  category=browser elapsed="279 ms" goroutine=168
ERRO[0031] communicating with browser: read tcp 127.0.0.1:50336->127.0.0.1:50330: wsarecv: An existing connection was forcibly closed by the remote host.  category=cdp elapsed="0 ms" goroutine=468
ERRO[0031] Exception executing xxxxWorkflow for browser test 6 companyId: xxxx  userName: xxxx exception: GoError: clicking on "[data-automation-id=\"xxxx-xxxx-view-button\"]": getting new document handle: getting document element handle: read tcp 127.0.0.1:50321->127.0.0.1:50320: wsarecv: An existing connection was forcibly closed by the remote host. stack: GoError: clicking on "[data-automation-id=\"xxxx-xxxx-view-button\"]": getting new document handle: getting document element handle: read tcp 127.0.0.1:50321->127.0.0.1:50320: wsarecv: An existing connection was forcibly closed by the remote host.
        at reflect.methodValueCall (native)
        at xxxxWorkflow (file:///c:/xxx/k6-browser-poc/src/apps/xxxx/xxxxWorkflow.js:13:4(18))
        at executeWorkflow (file:///c:/xxx/k6-browser-poc/main.js:109:27(8))
        at file:///c:/xxx/k6-browser-poc/main.js:42:12(75)  source=console
1 Like

Thanks @dnise01,

That’s useful information. Thanks for taking the time to explain all that. I appreciate :bowing_man: I’ll keep this in mind and bring to our attention. I suggest adding an issue on our Github with your finding if you like. That will allow the other team members to join the conversation in the future as well.

Thanks again.