Tutorials 27 August 2018

How to Set Up Automated Load Testing for Your WordPress Site (Or Any Other Platform)


📖What you will learn

  • How to set up automated load testing
  • How to load test a WordPress site
  • How to set up thresholds to define your success criteria

Load testing your site is vital if you want to make sure it can perform well under pressure. In fact, it’s a smart idea to run these tests frequently. However, this can be a time-consuming endeavor and can steal valuable time away from other tasks.


You can get around that problem by simply automating the load testing process. This way, you’ll be able to run as many tests as you’d like without disrupting your normal workflow. Plus, it will be easier for you to anticipate and deal with potential problems ahead of time.

In this post, we’ll discuss the basics of load testing and why you’d want to automate it. We’ll also show you how to set up automated load testing for your WordPress site. Let’s get started!

An Introduction to Load Testing


Load Impact helps you see how well your site performs under stress.

It should go without saying that testing is a fundamental part of development. It’s key to ensure that all aspects of a project are working properly, whether that project is an application, a website, or anything else.

When it comes to creating websites, one task you won’t want to overlook is load testing. This type of testing is used to gauge how well a site can perform under pressure, such as when it receives a sudden influx of traffic. Effective load testing allows you to create realistic scenarios so you can see how well your site copes under stress.

In most cases, a load testing tool works by creating a number of virtual users (VU) that ‘visit’ your site all at once. The results will show you, in real time, how your site’s loading times and general performance are affected by specific numbers of VUs. That makes this different from a standard speed test, which only checks how long it takes your site to load for one user.

You can run this kind of test at any time by using performance testing tools such as Load Impact. If you want to incorporate regular performance tests into your development cycle, the best solution is to automate those tests.

Why It’s Smart to Perform Automated Load Testing

Slow loading times are not just frustrating for users; they can be downright catastrophic for website owners. For every extra second a page takes to load, the likelihood of visitors giving up and going elsewhere increases significantly. This is known as your site’s ‘bounce rate’.

A slow site can also result in a poor browse the web for a few years now.

Performing regular load tests (instead of just once in a while or at the end of the development cycle) helps you spot issues with your site’s performance as soon as they arise. If you automate these tests, this process becomes fast and consistent.

What You Need to Do Before Load Testing Your Site

Before you can set up and configure your automated load tests, however, you’ll need to do a little preparation. First of all, this process does require that you are familiar with writing test scripts in a language such as JavaScript and working with a Continuous Integration (CI) tool.

You should also consider what you want out of the testing process before you set it up. Otherwise, the results you get may not be very helpful. Therefore, you’ll want to take the following steps:

  • Plan your tests. Decide how often and when you want to run your tests. This will naturally depend on your project, but a solid standard is to perform daily tests outside of ordinary working hours. This way, you’ll have the results ready when you start work each morning.
  • Define your goals. You need to consider what constitutes a successful and a failed test result. If you have a Service-Level Agreement (SLA) with your client, that’s a good baseline to start from.
  • Learn how to write test scripts. Once you have your plan and goals ready, you can implement them by creating test scripts.

When you’ve taken care of these tasks, you’ll be ready to automate your load tests. Let’s take a look at how that works in practice.

How to Set Up Automated Load Testing for Your WordPress Site (In 4 Steps)

The time has come to set up automated load tests for your WordPress site. This requires you to create your own test scripts and run them through an automated process as part of your Continuous Integration pipeline.

To do this, you can use Load Impact 4.0 solution, built on the our CI integration guides for more information.

Finally, it’s worth noting that while the following process works like a charm for WordPress sites, it’s not platform-specific. In other words, you can use this same method to set up automated load tests for your website, regardless of what platform you happen to be using.

Step 1: Download the k6 Tool


First, you’ll need to download and install k6. This is an open-source load testing tool, which can be integrated into any development cycle.

You can download the directly via the command line. For example, if you’re using Homebrew on Mac, you can run the following command:

$ brew tap loadimpact/k6
$ brew install k6

Once you’ve done that, k6 will be installed, and you can start using it via the k6 command line. We recommend that you familiarize yourself with k6 at this point, in order to understand what you can accomplish using this tool.

Step 2: Get a Load Impact API Token

To enable your CI tool to trigger tests with k6, you will require a Load Impact API Token. To get one, you’ll need to have a Load Impact account, which is completely free to try out.

You can sign up for an account from the Load Impact registration page:


Once your account is set up, you can access your API Token from this page:


Save the token, as you’ll need to use it when integrating your CI tool. For example, if you’re working with CircleCI, you would need to specify the API token as an environment variable.

Step 3: Use Thresholds to Define Success Criteria

Finally, it’s now time to run your load test. You can try one out right away by running the following test script:

k6 run github.com/loadimpact/k6/samples/http_get.js

This will start a test based on the specified external script, and display the results for you to review.

Naturally, you’ll most likely want to work with your own local scripts instead. To do this, you’d use the same command but instead point to a local script file, such as in this example: k6 run script.js

To build the actual script, you’ll need to use the options provided in k6 to set your parameters. These let you determine the tool’s behavior during the test, such as what should be tested, the duration, the thresholds, and so on.

The following example shows what your full test script might look like:

import http from 'k6/http';
export const options = {
hosts: {
'test.loadimpact.com': '',
stages: [
{ duration: '1m', target: 10 },
{ duration: '1m', target: 20 },
{ duration: '1m', target: 0 },
thresholds: {
http_req_duration: ['avg<100', 'p(95)<200'],
noConnectionReuse: true,
userAgent: 'MyK6UserAgentString/1.0',
export default function () {

Of course, you can customize your script using whatever parameters and options you want. You can then use the k6 run command as before to try it out.

After that, you can trigger the test using your CI tool. As we mentioned earlier, how this works will depend on the solution you’re using. For example, if you’re integrating with Jenkins, you can do this by executing the pipeline you’ve configured.

Step 4: Configure Test Notifications

Finally, you’ll need to set up notifications so you and your team are made aware when a test has concluded. This will also let you view the results as soon as they’re ready.

You can do this using several different chat tools, with the most popular option being Slack. However, k6 is also compatible with Webhook and HipChat.

To set up notifications, you’ll need to access your Load Impact profile and select the Integrations option from the main menu. When the new page opens, scroll down and find the options for connecting to Slack, HipChat, and/or Webhooks:


You’ll need a URL for each channel you want to use, which you can get directly from the service in question.

When you’re done, you’ll get automatic notifications whenever a load test has been completed. You’ll see them appear in your application of choice, so you can view the results right away!


Load testing is an important step when developing a website, as it helps you optimize your site for speed. A slow site leads to higher bounce rates and lost profits, so careful testing isn't something you can afford to skip. To save yourself some time and ensure consistency, you can even automate the load testing process.

In this article, we’ve shown you how to automatically load test your WordPress site using Load Impact. Just follow these steps to create an automated test:

  1. Download integrated with any CI solution.
  2. Get a Load Impact API token.
  3. Use thresholds to define success criteria.
  4. Configure test notifications.

Do you have any questions about automated load testing? Let us know in the comments section below!

Image credit: OpenClipart-Vectors.

< Back to all posts