Skip to content
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

[Heartbeat] Shared chrome browser for synthetics #32352

Open
andrewvc opened this issue Jul 14, 2022 · 5 comments
Open

[Heartbeat] Shared chrome browser for synthetics #32352

andrewvc opened this issue Jul 14, 2022 · 5 comments
Labels
enhancement Stalled Team:obs-ds-hosted-services Label for the Observability Hosted Services team

Comments

@andrewvc
Copy link
Contributor

andrewvc commented Jul 14, 2022

We could significantly reduce the memory requirements for on-premise nodes by sharing a chromium instance between concurrent tests. As-is memory usage is quite spikey since we use a full chromium process per run. We could easily share that instance using npx playwright-start or add a npx @elastic/synthetics server command to start a websocket server.

The following benchmarks show that running multiple tests concurrently using a shared chromium is significantly more economical than running a single test with its own isolated chromium instance.

TL;DR: It's close to a 40%~ reduction in memory to use a single chrome instance, saving hundreds of megs per test runner

See bottom of issue for sample scripts.

Results

Scenario 1: Run 5 clients against WS server, then 1 client

Five runners, total memory while connected to WS

Total peak runner mem=1.9GiB
Total peak server mem=1GiB
Mem per run=580MiB

plotclients5

Total peak runner mem=390MiB
Total peak server mem=520MiB
Mem per run=910MiB

Single runner, total memory while connect to WS

plotclients1

Chromium Websocket server while running 5 clients, then one client

plotserver
t

Single client, no websocket server

Total memory=790 MiB

plot1

Reproducing

Save the following runtest.sh script that can run 5x simultaneous runners

#!/bin/bash
set +x
echo Will run $1 times
ws=$(cat ~/.ws-endpoint | jq -r .wsEndpoint)
for i in $(seq 1 5);
do
 npx @elastic/synthetics --ws-endpoint=$ws journeys &
done
wait

Start the chromium server

npx playwright-start --headless

Monitor its memory

psrecord --include-children --plot plotserver.png <PIDOFSERVER>

Run the runners:

psrecord --include-children --plot=plotclients1.png ./runtest.sh

@andrewvc andrewvc added enhancement Team:obs-ds-hosted-services Label for the Observability Hosted Services team labels Jul 14, 2022
@elasticmachine
Copy link
Collaborator

Pinging @elastic/uptime (Team:Uptime)

@emilioalvap
Copy link
Collaborator

@andrewc ++, great poc! I'd love to see this implemented, it would reduce hardware requirements by a mile for concurrent monitors

@andrewvc andrewvc changed the title Shared chrome browser for synthetics [Heartbeat] Shared chrome browser for synthetics Jul 14, 2022
@botelastic
Copy link

botelastic bot commented Jul 14, 2023

Hi!
We just realized that we haven't looked into this issue in a while. We're sorry!

We're labeling this issue as Stale to make it hit our filters and make sure we get back to it as soon as possible. In the meantime, it'd be extremely helpful if you could take a look at it as well and confirm its relevance. A simple comment with a nice emoji will be enough :+1.
Thank you for your contribution!

@botelastic botelastic bot added the Stalled label Jul 14, 2023
@andrewvc andrewvc removed the Stalled label Jul 18, 2023
@andrewvc
Copy link
Contributor Author

Unlabeling as stale 👍

@botelastic
Copy link

botelastic bot commented Jul 17, 2024

Hi!
We just realized that we haven't looked into this issue in a while. We're sorry!

We're labeling this issue as Stale to make it hit our filters and make sure we get back to it as soon as possible. In the meantime, it'd be extremely helpful if you could take a look at it as well and confirm its relevance. A simple comment with a nice emoji will be enough :+1.
Thank you for your contribution!

@botelastic botelastic bot added the Stalled label Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Stalled Team:obs-ds-hosted-services Label for the Observability Hosted Services team
Projects
None yet
Development

No branches or pull requests

3 participants