From Wikitech
Jump to navigation Jump to search


In the path to have more stable metrics in our synthetic testing we have been trying out mahimahi, mitmproxy and WebPageReplay to record and replay Wikipedia. For mahimahi we have used patched version fixed by Gilles over Benedikt Wolters HTTP2 version of With mitmproxy and WebPageReplay we use the default version. The work has been done in T176361.

We have put mahimahi on ice because it is too much of hack to get HTTP/2 to work at the moment and WebPageReplay works out of the box with HTTP/2. mitmproxy worked fine but offered no clear benefit over WebPageReplay.

Replaying vs non replaying

Let us compare what the metrics looks like comparing WebPageTest vs WebPageReplay (Chrome).

Compare emulated mobile First Visual Change on Obama
Compare emulated mobile Speed Index on Obama
First Visual Change on Desktop using WPT vs WebPageReplay
Compare Speed Index on Desktop using WPT vs WebPageReplay

WebPageReplay setup

The current version run that collects the data for is a Docker container with this setup: and the setup looks like this:

WebPageReplay setup

Running on AWS (instance type c5.xlarge) we get stable metrics. We have tried running the same code on WMCS, bare metal and Google Cloud and in all those cases the metrics stability over time was at least 2 to 4 times worse than AWS. This difference remains unexplained and probably lies somewhere in AWS's secret sauce (custom hypervisor, custom kernel).

On desktop we can use 30 frames per second for the video and we get a metric stability span of 33 ms for first visual change. Which is 1 frame of accuracy, since at 30fps one frame represents 33.33ms. Speed Index's stability span is a little wider but still ok (less than 50 points but it depends on the content).

For emulated mobile, we can use 30 frames per second but we seen that it would also work with 60 fps but somewhere we will hit the limit of the browser and OS. We run the both desktop and mobile with 100ms simulated latency during the replays.


We run tests from two servers at the moment:

  • - Run tests on emulated mobile for WebPageReplay and user journeys
  • - Run tests on desktop with WebPageReplay for both Firefox and Chrome

Access the servers with the pem file:

# Running emulated mobile tests
ssh -i "sitespeedio.pem" ubuntu@ 
# Running desktop tests
ssh -i "sitespeedio.pem" ubuntu@

Setup a new server

Here are the details of our current setup. We currently run desktop and emulated mobile Chrome tests on a C5.xlarge VM on AWS using Ubuntu 18.


Install it manually:

  1. Install Docker and grant your user right privileges to start Docker.
  2. Create a config directory where we place the secrets (AWS keys etc): mkdir /config
  3. Clone the repo (in your home dir) with the tests:git clone
  4. Take a copy of the /config/secret.json file that exists on of the current running servers and add it to /config/

Also make sure the script start on server restart. When you start the script you choose which tests to run, by pointing out one or multiple test directories. That means that starting the tests looks differently on different machines.

Run crontab -e

And add @reboot rm /home/ubuntu/performance-synthetic-monitoring-tests/;/home/ubuntu/performance-synthetic-monitoring-tests/ THE_TEST_DIR

That will remove the run file and restart everything if the server reboots.

The last step is to create a welcome message to you when you login to the server. Run sudo nano /etc/profile.d/

echo "This server runs tests testing Desktop Wikipedia using WebPageReplay"
echo "Start: nohup /home/ubuntu/performance-synthetic-monitoring-tests/ TEST_DIR &"
echo "Stop: rm /home/ubuntu/performance-synthetic-monitoring-tests/ && tail -f /tmp/"

Make sure to change the TEST_DIR and the message match what you run on your server.

Setup AWS monitoring

When you create a new instance, you also need to setup monitoring on that instance on AWS. Setup alarms for network outgoing traffic (NetworkOut) and set the alarm if it is <= 0 bytes for 3 out of 3 points for 1 hour. Assign the alert to the email group Performance-alerts.

Start and restart

You start by giving it the folder to test. If we test all desktop tests on the same machine we do that with:

Start the script:  nohup /home/ubuntu/performance-synthetic-monitoring-tests/ replayDesktop &

Restart: First remove /home/ubuntu/performance-synthetic-monitoring-tests/ and then tail the log and wait for the script to exit. Then start as usual.


You can find the log file at /tmp/ There you can find all log entries from

Upgrade to a new version

Checkout the runbook for updating the version.


We also run alerts on the metrics we collect from WebPageReplay. Checkout Performance/WebPageReplay/Alerts.