K6 incredibly bad ram usage

Hello guys !
I am currently working on a load testing using k6’s browser .There is no way i can make it using http.get because it requires ui interactivity .
I made a script that logins and then in an infinite loop keeps on clicking random navigators , because i want the load to go up to 5000 vus . Is there a better way ?
I was preparing the script and when i ran it on a linux vm the instances consume ram like nothing else . 100 vus for 20 gb ram ?
Also when i ran on windows i saw that the chromium instnaces had different ram usage but the linux vm as k6 loads more vus , altogether the vus consume more and the exact same amount of ram .

Is there any solution for that ?
I would appreciate any help very much

Hi @kkrasovitskiy,

Each iteration launches a new Chromium process. Connecting to the same Chromium instance might help to reduce the RAM usage. You first need to start a Chromium browser in debug mode, get a WebSocket URL, and finally connect to it:

Launch Chromium

  chromium \
    --user-data-dir=$(mktemp -d) \
    --remote-debugging-port=$RANDOM_PORT \
    --disable-popup-blocking \
    --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 \
    --disable-extensions \
    --disable-prompt-on-repost \
    --disable-renderer-backgrounding \
    --no-default-browser-check \
    --mute-audio \
    --disable-background-timer-throttling \
    --disable-dev-shm-usage \
    --disable-hang-monitor \
    --disable-ipc-flooding-protection \
    --force-color-profile=srgb \
    --no-sandbox \
    --disable-component-extensions-with-background-pages \
    --disable-backgrounding-occluded-windows \
    --metrics-recording-only \
    --no-startup-window \
    --window-size=800,600 \
    --hide-scrollbars \
    --disable-background-networking \
    --enable-automation \
    --use-mock-keychain \
    --disable-breakpad \
    --disable-default-apps \
    --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,AcceptCHFrame \
    --no-first-run \
    --password-store=basic \
    --no-service-autorun \
    --enable-features=NetworkService,NetworkServiceInProcess \
    --enable-logging \
    --vmodule='devtools_*=1' \
    --enable-logging=stderr \
    --v=2 \
    --start-maximized \
    --disable-infobars \    
    --headless

Note: Change the “chromium” part to your Chromium executable. Or, it should in the PATH environment variable.

Connect to the same Chromium

K6_BROWSER_WS_URL='WEBSOCKET_URL_HERE' k6 run script.js

Hope this helps.