Catchpoint WebPageTest Documentation

WebPageTest System Design

WebPageTest is made up of several components that work together to provide the full end-to-end experience. There are 2 primary components to WebPageTest:

WebPageTest server: PHP-based component that runs the main UI, API endpoints and manages the queuing and processing of the tests.

wptagent: Python-based cross-platform (Linux, Windows, MacOS, iOS, Android, Raspbian) component responsible for running tests and posting the results to the WebPageTest server.

Additionally, there are several utilities used by the main components or helper scripts for automating installation:

wptserver-install: Installation script for automating the install of a new WebPageTest server with Nginx and php-fpm on an Ubuntu server instance.

wptagent-install: Installation script for automating the install and configuration of wptagent on an Ubuntu server image and MacOS (including browser installation, automatic agent startup and updating, etc).

iWptBrowser: On-device iOS component that works with wptagent for iOS device testing.

win-shaper: Windows implementation of packet-level traffic-shaping similar to dummynet and used by wptagent on Windows.

vpn-reverse-tether: Android implementation of reverse-tethering for use by wptagent when testing Android devices.

browser-install: Windows helper utility for installing browsers and keeping them up to date.

WebPageTest Server

Processing Flows

Submitting a test

Submit test flow
All tests are submitted through the runtest.php entrypoint. The UI pages for submitting tests are just forms that populate the appropriate API parameters. Resubmitting an existing test is a slight exception in that it doesn't provide all of the test params in the call to runtest.php, it passes the existing test ID and runtest.php loads all of the params from the existing test.

runtest.php does a fair bit of processing to the request before generating the test job:

Test Processing

Once a test has been queued, both the test Agent and User operate on the test, waiting for it to be complete:

Agent:

User

Test Archiving

WebPageTest can be configured to archive tests to a central archive for long-term storage, using the local storage as a cache and while tests are being processed.

When archiving is configured, tests will be stored into the archive (but not deleted) as soon as a test is complete.

There is an hourly "cron" (cron/hourly.php) that is triggered by agents polling for work that will run the archive script (cli/archive.php). Tests will be deleted after the configured archive time has passed since they were last accessed.

When a test is accessed, common.inc will see if the test is available locally. If it is not and an archive endpoint is configured, it will attempt to restore the test from the archive. This will allow any front-end WPT server to view any test that is available in the archive, even if the test was created on a different server.

Every time the test is accessed, the main test file is "touch"ed so the last accessed time of the test can be updated.

Load Balancing Multiple Servers

WebPageTest servers are largely independent but they can be run in parallel for high-availability or to scale thruput. Tests are "sticky" to the server that they were created on but there are several server settings (settings.ini) that are needed to make it work smoothly.

The settings.ini configuration is a combination of the settings in 3 different files which allows for a shared site-specific configuration as well as server-specific overrides:

Once the servers have unique ID's and can be configured to sync with each other then the servers can run transparently behind a load-balancer. The load balancer needs to be configured to route requests that have a URL that includes \d\d\d\d\d\d_Ai to the "A" server (etc for each server ID) and other requests can be balanced randomly.

wptagent

Testing Flow

Class Hierarchy