Speed & performance · Guide
How to Load Test a WordPress Site Before a Launch
Short answer
Load test a WordPress site on a staging copy with a tool such as k6 or JMeter, starting from your real peak traffic and raising the load in steps. Set pass limits for response time and error rate before the run, then fix the bottleneck the test exposes and re-run the same test.
Key takeaways
- Never load test the live site; use a staging copy on the same hosting plan.
- Start from real peak traffic, then test at baseline and twice baseline.
- k6 runs JavaScript scripts from the command line; JMeter builds visual test plans.
- Set pass limits for response time and error rate before the run.
- Re-run the same test after each fix to prove it worked.
What is load testing?
Load testing means sending simulated traffic at your site and watching how it responds, so you find the breaking point before real visitors do.
A load test replays the same requests many users would make at once. It records response times, error rates and throughput, then shows where the site slows down or fails.
Load testing differs from a speed audit. A speed audit measures one page load in isolation, while a load test measures how the site holds up when many people arrive together.
The goal is a number you can act on. You want to know how many simultaneous visitors the site handles, which page fails first, and what resource runs out.
What do you need before you load test a WordPress site?
You need a staging copy of the site, a load testing tool, and written permission from your host.
Never load test the live site. A heavy test can slow the live site for real visitors, fill the database with test orders, and trigger rate limits or a host abuse warning.
Build the staging copy on the same hosting plan and the same server size as the live site. A test on a larger staging server tells you nothing about the live server.
List the pages that matter most before you start. A home page, a popular post, a product page, the cart and the checkout each behave differently under load.
Decide your pass limits in writing before the run. Pick a maximum response time, a maximum error rate and a minimum throughput, so the result is a clear pass or fail.
Tell your host the test date, the expected traffic level and the staging URL. Some hosts block sudden traffic spikes as an attack, so a short heads-up avoids a blocked test.
Which load testing tool should you use?
Pick the tool that matches your comfort with code, because all three options below can run a useful WordPress test.
| Tool | How it works | Cost | Best for |
|---|---|---|---|
| Grafana k6 | JavaScript scripts run from the command line | Open source, free to run | Developers who want versioned, repeatable tests |
| Apache JMeter | Desktop app with a point-and-click test plan | Open source, free | Testers who prefer a visual interface |
| Loader.io | Hosted service run from a browser form | Free plan plus a monthly Pro plan | A quick capacity check with nothing to install |
k6 is a good default for WordPress teams that already use the command line. Grafana describes k6 as open source, and its scripts are plain JavaScript files you can keep in version control next to the site code.
JMeter suits teams that want a visual builder. Apache JMeter builds each test as a tree of elements, starting with a Thread Group that sets the number of users, the ramp-up period and the loop count.
Loader.io suits a one-off check. Loader.io states that all tests run from Amazon's US-east datacenter, and its subscriptions run month to month with no long-term contract.
How do you write your first k6 load test?
A k6 test is a short JavaScript file that describes what one virtual user does, then repeats it for as many users as you set.
- Install k6 from the Grafana k6 installation guide for your operating system, then confirm it with
k6 version. - Create a starter script with
k6 new, which writes a file namedscript.jsin the current folder. Grafana documents this command as the first step of a local test. - Open
script.jsand replace the target URL with your staging home page. - Add the pages that matter, such as a post and a product page, and add a one-second pause between requests with
sleep(1). - Set your pass limits as thresholds, for example a 95th-percentile response time under 500 ms and a failed-request rate under 1 percent.
- Run the test with
k6 run script.jsand read the summary table at the end.
A basic script looks like this:
import http from 'k6/http';
import { check, sleep } from 'k6';
export const options = {
vus: 10,
duration: '30s',
thresholds: {
http_req_duration: ['p(95)<500'],
http_req_failed: ['rate<0.01'],
},
};
export default function () {
const res = http.get('https://staging.example.com/');
check(res, { 'status is 200': (r) => r.status === 200 });
sleep(1);
}
The command k6 run --vus 10 --duration 30s script.js runs the same script with 10 virtual users for 30 seconds. Grafana documents both flags, and notes that virtual users are parallel loops, so more users means more simulated traffic.
Keep the first run tiny: 10 users for 30 seconds. A small run proves the script works, the staging URL answers, and the checks pass, before you spend real time on a large run.
How do you build a JMeter test plan for WordPress?
A JMeter test plan is a tree of elements, and you build it by adding a Thread Group, samplers and a listener.
- Open JMeter, right-click Test Plan, and choose Add, then Threads, then Thread Group.
- Name the group, set Number of Threads to 10, set Ramp-Up Period to 10 seconds, and set Loop Count to 5.
- Right-click the Thread Group, choose Add, then Config Element, then HTTP Request Defaults, and enter your staging host name.
- Add an HTTP Cookie Manager under the Thread Group so login sessions and cookies work across requests. Apache JMeter notes that the Cookie Manager is how cookie support is added to a Thread Group.
- Add one HTTP Request sampler per page: the home page, a post, and a product page.
- Add a listener such as View Results Tree to store and inspect the results, then save the plan as a
.jmxfile.
The Thread Group is the heart of the plan. Apache JMeter explains that it tells JMeter the number of users to simulate, how often they send requests, and how many requests they send.
The JMeter manual's own web test example uses 5 users, a ramp-up of 1 second and a loop count of 2. Start near those numbers for your first run, then raise them in steps.
Run the plan in the GUI once to debug it, then run the real test from the command line with jmeter -n -t plan.jmx -l results.jtl. The GUI uses extra memory, and a heavy GUI run can distort the result.
How many virtual users should you test with?
Start from your real traffic, not from a round number, because a test that is far above real traffic proves little.
Open Google Analytics and find the busiest hour of the busiest recent day. Note the number of active users in that hour, then convert it to simultaneous users with a simple rule: divide the hourly page views by 3,600 and multiply by the average time a visit lasts in seconds.
A site with 3,600 page views in its busiest hour and an average visit of 60 seconds has about 60 simultaneous visitors. That figure is your baseline load, and the test should cover at least twice that number to leave room for growth.
Test in three stages. Run a smoke test with 1 user for 30 seconds, a load test at your baseline number for 5 minutes, and a stress test at twice the baseline to find the breaking point.
Raise the load in steps of 25 to 50 percent, never in one jump. A sudden jump from 10 users to 1,000 hides the point where response times first climb.
How do you read the results?
Read four numbers first: response time, error rate, throughput and the point where the site bends.
Response time is usually reported as percentiles. The p95 value means 95 percent of requests were faster than that number, and it is a better guide than the average, which hides slow outliers.
Error rate is the share of requests that failed. A rate above 1 percent during a normal load test means the site is already struggling, even if the average response time still looks fine.
Throughput is requests per second. It should climb as you add users, then flatten. The flat point is the site's capacity, and adding more users past it only raises response times.
What mistakes ruin a load test?
Testing the live site is the worst mistake, because it risks real visitors and real orders.
Testing with the cache off is the second mistake. WordPress pages behave very differently cached and uncached, so test both states and label each run clearly. A fresh cached response needs no server trip at all, according to MDN, so a test that ignores the cache measures a different site than visitors use.
Testing only the home page is the third mistake. A site can serve a cached home page to thousands of users while the checkout collapses under ten, so include the pages that do real work.
Forgetting login is the fourth mistake. Logged-in pages skip the page cache and run more database queries, so a test that never logs in misses the heaviest traffic a site sees.
Running the test from your own laptop over home internet is the fifth mistake. Your connection becomes the bottleneck, and the result measures your network rather than the server.
What do you fix first after a load test?
Fix the bottleneck the test exposed, starting with the resource that hit its limit first.
When the database is the limit, look at slow queries and uncached options. Start with the checks in our guide to fix database tables that need repair, which covers the repair steps that apply when tables are damaged or slow.
When PHP or CPU is the limit, check the PHP version and the object cache. Our guide on whether the PHP version affects WordPress speed explains why the version matters.
For the cache layer, read our comparison of Redis versus Memcached for WordPress, which covers the two object cache options.
When the server itself is the limit, the fix may be a larger plan or a different host. Run the checks in our guide to test hosting speed before buying before you move, so the next host is measured rather than guessed.
Re-run the same test after each fix, with the same user count and the same pages. A fix that is not measured is only a guess, and the re-run is what proves it worked.
Frequently asked questions
Can I load test the live site directly?
No. A load test can slow the live site, fill the database with test orders and trigger host abuse warnings. Always test a staging copy on the same hosting plan and server size as the live site.
How many virtual users should I start with?
Start with 1 user for 30 seconds to prove the script works, then test at your real peak simultaneous visitor count for 5 minutes. Finish with a stress test at twice that number to find the breaking point.
Which numbers matter most in the results?
The p95 response time, the error rate, throughput in requests per second, and the point where response times first climb. The p95 matters more than the average because it shows what the slowest 5 percent of visitors felt.
Do cached and uncached pages need separate tests?
Yes, and you should test both states. A cached page can serve thousands of visitors while an uncached checkout fails under ten. Label each run clearly so you know which state you measured.
Which pages should a WordPress load test cover?
Test the home page, a popular post, a product page, the cart and the checkout, because each behaves differently under load. Include at least one logged-in flow, since logged-in pages skip the page cache.
How do I know a fix actually worked?
Re-run the exact same test with the same user count and pages. If the p95 response time falls and the error rate stays under 1 percent, the fix worked. A fix without a re-run is only a guess.
Sources
- Running k6 Grafana k6 documentation
- Building a JMS Topic Test Plan Apache JMeter
- Pricing Loader.io
- HTTP caching MDN
Is your product missing, or something out of date?
Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.
Thanks — we review requests within 3 business days.
