Setting up WebPageTest Private Instance in AWS EC2

Senthil Kumar
4 min readFeb 16, 2021

In my opinion, WebPageTest.org is by far the best open-source web performance tool. You can find the source in GitHub and WPT Private Instance can be found here. WPT also has bunch of EC2 test agents for you to use.

In this article I will explain the steps to bring up:

  1. WPT Server
  2. WPT Client
  3. Connect Server and Client
  4. How to connect WPT Bulk Tester to talk to WPT Private Server.

Prerequisite:

  1. Get a new/existing IAM with EC2 Key and Secret. Make a note of the key and secret. Lets call this — wpt-iam
  2. Create a S3 Bucket. Lets call it — wpt-bucket

Setting up WPT Server:

Launch a New Instance.

Search for the AMI — “ami-fcfd6194” and select it.

Choose the Instance type that fits you.

In the “Configure Instance Details”, make a note of the VPC, Subnet you are using. (We will use the same VPC and Subnet for both Server and Client to make things easier)

In the “Configure Security Group”, choose an existing SG or create one and allow SSH, 80 and 443 ports to your IP. (Note that we will need SSH access to check logs, update Locations and settings). Lets call this SG — wpt-sg

Review and Launch >> Launch

Make sure get grab the ssh keys upon launch.

Now go ahead and assign an Elastic IP to this server.

Lets Name the server something appropriately — “wpt-server

All Done.

Let’s check if the server is up by hitting the Elastic IP in a browser.

Now go to http://your-ip-here/install and make sure its all green except for the Test Locations.

Setting up WPT Client:

  1. Launch a new Instance
  2. Search for the AMI — “ami-0137821046846369e” and select it. You could use other WPT Agents of your choice.
  3. In the Configure Instance Details, choose the same VPC that you used for the server.
  4. Towards the end of the Configure Instance Details add the following User Data:

wpt_server=<Server’s Elastic IP>
wpt_location=<Name of this Agent>

5. In the “Configure Security Group”, choose the same SG as the server or create one with SSH, 80 and 443 ports.

6. Finish and Launch.

7. Assigning an Elastic IP to the client is optional.

8. Lets Name the server something appropriately — “wpt-agent

9. All Done.

Connect Server and the Client:

  1. Hit the server IP to see if WPT loads.
  2. SSH to the server and update settings.xml and location.xml appropriately.

Path — /var/www/webpagetest/www/settings/

3. Location.xml sample below.

[locations]
1=Test_Client
default=Test_Client
;
[Test_Client]
1=Test_Client_wptdriver
2=Test_Client_IE11
label=”Test_Client agent”
default=Test_Client_wptdriver
;
[Test_Client_wptdriver]
browser=Chrome,Firefox
label=”Test_Client agent with wptdriver”
;
[Test_Client_IE11]
browser=IE 9
label=”Test_Client tester agent”

4. settings.xml sample below.

# User to start/stop agents and save tests to s3
ec2_key=
ec2_secret=
# show user timing marks in waterfalls — very handy
waterfall_show_user_timing=1
iq=75
pngss=1
# archiving to s3
archive_s3_server=
archive_s3_key=
archive_s3_secret=
archive_s3_bucket=
# number of days to keep tests locally before archiving
archive_days=1
# run archive script hourly automatically as agents poll for work
cron_archive=1

5. Restart apache and tail the logs and check if you see the Client private IP. If you see this, it’s working as expected and the client is talking to the server.

How to connect WPT Bulk Tester to talk to WPT Private Server:

  1. SSH to the server and add an API key.

/var/www/webpagetest/www/settings/keys.ini

2. Make a copy of WPT Bulk Tester .

3. In the above google sheet, add the server IP and API Keys in settings sheet.

4. Update the Scenarios sheet to match your location + browser.

5. All set.

--

--