Playwright Load Testing: What Works, What Breaks, and What to Run Instead
Playwright is not a load tool. Reuse checkout.spec.ts, pair k6 for volume, measure Web Vitals, and stop saturating CI workers.
Teams keep asking Playwright to stand in for a crowd of shoppers. They already have checkout.spec.ts, and they want that same script to prove the site will survive a sale.
What they get instead is a red CI job, Timeout 30000ms exceeded, and a report that says the tests failed. The app might be fine. The runner just ran out of CPU.
This guide walks through what Playwright load testing can and cannot do, why workers are the wrong knob, and a hybrid method that reuses that checkout spec without pretending eight browsers are eight thousand users.
Use this table as the map for the rest of the page. If the left column is what you ran on Friday, move to the right column before you open a performance ticket.
| What you ran | What that actually is | What to run for load |
|---|---|---|
| npx playwright test --workers=20 | More E2E worker processes on one CI box | A load tool's virtual users, with a ramp and a hold |
| --repeat-each=10 | The same spec again, for flake hunting | Arrival rate and duration in k6 or Artillery phases |
| waitUntil: 'networkidle' | Wait for 500 ms with no network, often a timeout | domcontentloaded or load, then assert Pay |
| One shared qa@shop.example.com | Cart races that look like capacity bugs | One email and cart per virtual user |
| Green checkout.spec.ts | Pass or fail for one browser session | p95 over time, plus a few canary browsers for LCP |
Playwright load testing is not a test-runner feature
Playwright Test is an end-to-end runner. It starts worker processes, each worker starts its own browser, and each test gets a pass or fail. That belongs with Playwright E2E testing. A load profile is a different kind of report.
A load test asks how the system behaves as arrivals rise, hold, and fall. It reports percentiles over time. It does not care that test('pays with Visa') is green on one laptop.
The confusion starts because both jobs click Pay. Your spec already logs in, adds a desk, and submits a card. Someone on the call says, run that twenty times at once. --workers=20 looks like Playwright load testing. It is still one test run, just noisier.
A worker is an OS process. You cannot talk between workers. Each one starts its own browser. The runner reuses a worker across files when it can, then kills it after a failure so the next test gets a clean process. That design protects test automation isolation. It does not model think time, ramp, or arrival rate. Playwright load testing needs those three things, plus a report that moves over time.
A Playwright worker is a process that runs tests. A virtual user (VU) is a concurrent session in a load tool. One worker is not one shopper. Twenty workers on a 2-CPU runner are twenty hungry browsers fighting for the same cores.
Artillery draws the same split in practice. Playwright Test runs specs once and returns pass or fail. A load runner runs a smaller journey many times in parallel and shows how timings move while the crowd is on the site.
k6 draws the line another way. Protocol tests send HTTP. Browser tests drive Chromium. Hybrid tests do both. Playwright can be the browser half of that picture, and only if something else schedules the VUs.
Playwright browser testing across Chromium, Firefox, and WebKit is still the right gate for a UI change. Playwright load testing against a sale is a different job, and Chromium-only is often enough there. Extra engines just slow a large run.

If you only needed Playwright to prove checkout still works after a CSS change, stop here. Keep the spec. Do not turn the CI job into a crowd.
What a real load test has to prove
Useful Playwright load testing on checkout has to prove three things. The API can take the arrivals you expect. The page still paints for a real browser while that traffic is on. Failures look like product failures, not generator starvation.
Protocol load covers the first proof. You send POST /api/cart and POST /api/pay with a tool built for volume. Those scripts download responses. They do not paint the page.
Browser load covers the second proof. A real engine runs JavaScript, builds the DOM, and fires the APIs your UI actually calls. That is why people pair Artillery with Playwright. Dynamic apps call different endpoints based on clicks. A HAR replay goes stale the week the frontend ships a new bundle.
The third proof is the one CI teams skip. If the generator is slower than the app, your p95 is a lie. Plan about one vCPU per concurrent browser. Pack more browsers on one box and Web Vitals fall because the browser is hungry, not because checkout is.
Core Web Vitals give you the user-facing bar. A good LCP is within 2.5 seconds. A good INP is 200 milliseconds or less. A good CLS is 0.1 or less. Judge them at the 75th percentile.
Those three metrics use different units, so they do not share one graph. Use this table instead.
| Metric | What it measures | Good threshold (75th percentile) |
|---|---|---|
| Largest Contentful Paint (LCP) | Loading | within 2.5 seconds |
| Interaction to Next Paint (INP) | Interactivity | 200 milliseconds or less |
| Cumulative Layout Shift (CLS) | Visual stability | 0.1 or less |
Those numbers are the usual "good" bar for loading, interactivity, and layout shift.
So pick the question before you pick the tool.
| Question you need answered | Tool that owns it | What Playwright Test gives you instead |
|---|---|---|
| Can pay handle 2,000 requests per minute? | k6, JMeter, or another protocol runner | One or two request.post calls in a spec |
| Does LCP stay under 2.5s while pay is busy? | A few real browsers during that protocol run | A single headed or headless pass/fail |
| Does the Visa button still submit after a UI change? | Playwright Test in CI | That is the job it was built for |
Playwright API testing still belongs next to Playwright load testing. Use APIRequestContext to seed an order or assert the server wrote the payment. Do not use it as a VU generator. Setup and teardown are not an arrival rate.
And keep Playwright locators in the browser half. getByRole('button', { name: 'Pay now' }) is how a user finds Pay. A protocol script never looks at that button.
Park locators, traces, and sharding with the rest of your Playwright testing hub work. Playwright load testing sits beside that, not inside npx playwright test.
Why raising workers is a false load test
Raising --workers makes the suite finish faster, until the machine is full. Then tests time out. Then you think checkout melted. Often you melted the runner. That is not Playwright load testing. It is a tired CI box.
Playwright's CLI default is 50 percent of logical CPU cores. On a private GitHub-hosted ubuntu-latest runner that is 2 CPUs and 8 GB of RAM, so the default is one worker. On a public ubuntu-latest runner that is 4 CPUs and 16 GB, so the default is two. Those are the usual hosted sizes.
--workers=20 on the private runner is ten times the cores you paid for. The bar chart below is that hardware fact, not a load-test result.
On CI, start with workers: 1 so each test gets the full box. If you have a strong self-hosted runner, you can raise it. For more throughput use Playwright sharding, which splits files across jobs. Sharding is still one suite, cut into pieces. It is not 200 shoppers on staging.
A small Docker class often has 2 cores. Playwright sizes workers to that count. Going above it is a common way to buy timeouts.
Here is the config most teams already have.
import { defineConfig } from '@playwright/test';
export default defineConfig({
// Opt out of parallel tests on CI.
workers: process.env.CI ? 1 : undefined,
retries: process.env.CI ? 2 : 0,
// Stop the run yourself so reporters still write a report.
globalTimeout: 60 * 60 * 1000,
use: {
trace: 'on-first-retry',
screenshot: 'only-on-failure',
video: 'retain-on-failure',
},
});
globalTimeout is easy to skip, and it matters the moment someone treats CI like a soak. By default a run has no upper bound. The GitHub job then kills the process mid-run and you get no HTML report. Set globalTimeout so Playwright stops first. If you also set timeout-minutes on the workflow, keep it above that value.
Now look at the command that showed up in the Friday incident. That is how fake Playwright load testing usually starts.
npx playwright test tests/checkout.spec.ts --workers=20 --repeat-each=10
--repeat-each reruns the same test N times. The CLI default is 1. That flag hunts flakes. It does not ramp traffic. Twenty workers times ten repeats is 200 browser sessions stacked on a box that may have two cores.
The failure you will see looks like this.
TimeoutError: page.goto: Timeout 30000ms exceeded.
=========================== logs ===========================
navigating to "https://shop.example.com/checkout", waiting until "networkidle"
============================================================
networkidle waits until there are no network connections for at least 500 ms. That wait is a poor default for this work. Analytics, chat widgets, and payment iframes never go quiet, so the navigation burns the whole 30 seconds. Under CPU contention it fails even sooner.
Playwright in GitHub Actions already fights for those two cores. Traces, video, and the HTML report add more disk and CPU. Playwright reporting will show a wall of red. That red is generator noise until you prove otherwise.
There is a cleaner check in current Playwright. Set retryStrategy: 'isolated'. Failed tests retry after the suite, one at a time, on a single worker. If checkout fails in the parallel run and passes isolated, the spec is probably fine. The machine was the bottleneck. The 1.62 notes spell that split out.
Tip: If checkout fails at --workers=8 and passes at --workers=1 with retryStrategy: 'isolated', do not open a performance ticket yet. Open a runner-sizing ticket.
Shared data makes the false load test worse. Two workers that both log in as qa@shop.example.com race the same cart. Derive ids from testInfo.testId, or isolate users with testInfo.workerIndex. Skip that, and you will see "cart is empty" while you think you found a capacity bug.
Playwright also has named test locks for a shared resource that cannot run concurrently, such as a global promo flag. Locks serialize those tests across files and workers. That is an E2E safety rail. It is still not a load profile. In a real soak, each VU needs its own promo code, not a lock that makes everyone wait.
Playwright assertions then retry for 5 seconds on a page that never settles. The spec looks flaky. The root is still the box.

A hybrid method: protocol load plus a few real browsers
The method that holds up for Playwright load testing is hybrid. Generate most of the traffic at HTTP. Keep a small number of real browsers on the same journey so you can see what a person would see.
Start with 10 percent browser VUs or less. Let protocol traffic carry around 90 percent. Browser VUs have extra overhead. Resource use depends on the app under test.

Two bars show protocol virtual users at ninety percent and browser virtual users at ten percent as k6 starting guidance
Protocol scripts are cheap. Browser scripts start Chromium. Mixing them in one run gives backend volume and frontend timings without a warehouse of machines.
That is the canary-browser method for checkout.spec.ts. k6 (or JMeter) soaks POST /api/pay. Two or five Playwright browsers walk login, cart, and Pay on staging at the same time. You compare LCP and TTFB while the API is idle, then while it is busy.
The same split shows up in hosted load products too. You do not need a new platform to use it.

k6's browser module looks like Playwright. It is not Playwright. k6 allows one browser context at a time. A second browser.newContext() throws existing browser context must be closed before creating a new one. If your Page Object opens extra contexts, you will rewrite that part.
A compact hybrid script looks like this.
import { browser } from 'k6/browser';
import http from 'k6/http';
export const options = {
scenarios: {
load: {
exec: 'hitPayApi',
executor: 'ramping-vus',
stages: [
{ duration: '2m', target: 50 },
{ duration: '5m', target: 50 },
{ duration: '1m', target: 0 },
],
},
canary: {
exec: 'walkCheckout',
executor: 'constant-vus',
vus: 2,
duration: '8m',
options: { browser: { type: 'chromium' } },
},
},
thresholds: {
http_req_failed: ['rate<0.01'],
http_req_duration: ['p(95)<500'],
browser_web_vital_lcp: ['p(95)<2500'],
},
};
export function hitPayApi() {
http.post('https://shop.example.com/api/pay', JSON.stringify({ sku: 'desk-1' }), {
headers: { 'Content-Type': 'application/json' },
});
}
export async function walkCheckout() {
const page = await browser.newPage();
try {
await page.goto('https://shop.example.com/checkout');
await page.locator('[data-testid="pay-now"]').click();
} finally {
await page.close();
}
}
k6 run k6-checkout-hybrid.js
Thresholds in that script follow k6's sample shape. The 2.5 second LCP cap matches Google's good LCP target on web.dev. Your product may need a tighter number. Set it from production RUM, not from a guess.
Artillery when you want Playwright APIs at VU scale
If the team already has Page Objects and wants those same page.click calls under a ramp, Artillery's Playwright engine is the path that reuses the API. Artillery creates VUs from config.phases. Each VU runs your function against a page Artillery created. It records LCP and FCP as the crowd grows.
import { Config, Scenario } from 'artillery';
export const config: Config = {
target: 'https://shop.example.com',
engines: {
playwright: {},
},
phases: [{ duration: 300, arrivalRate: 1, maxVusers: 20 }],
};
export const scenarios: Scenario[] = [
{
engine: 'playwright',
testFunction: helloCheckout,
},
];
async function helloCheckout(page: any) {
await page.goto('https://shop.example.com/checkout');
await page.getByRole('button', { name: 'Pay now' }).click();
}
npx artillery run artillery-checkout.ts
Artillery currently runs Chromium only for these tests. Distributed runs go to AWS Fargate or Azure ACI. Lambda is not a fit. Keep those limits in mind when you size a run.
Cost is why you still keep VU counts honest. Five thousand concurrent browsers is expensive, and one vCPU per browser is a safe starting guess. Data transfer can add more. There is no fixed formula for VUs per worker. Raise the count only while Web Vitals stay stable.
Who should skip this swarm: anyone who only needs API throughput. Use k6 HTTP and leave Playwright in CI. Also skip thousands of browsers if you cannot budget about one vCPU per VU. A starved generator will report a slow site that is actually a slow laptop.
Who should run a small swarm: QA owners of a revenue journey who already trust checkout.spec.ts and need Web Vitals while backend load is on. Two to twenty browsers is enough for most Playwright load testing on that path, not two thousand, until the metrics are stable.
Playwright best practices still apply on those few browsers. Isolated data. Role locators. No waitForTimeout. The load tool does not fix a brittle spec.
Network mocking is the exception. page.route() that fulfills /api/pay with a stub removes the backend from the test. That is right for a UI unit. It is wrong for load. Let the real pay API take the hit, or you will measure a mock.
Reuse checkout.spec.ts without breaking CI
Keep the CI job as a functional gate. Extract the journey so Playwright load testing does not live in the PR workflow. Do not point --workers=20 at the same job that blocks the merge.
The Friday spec probably looks like this.
import { test, expect } from '@playwright/test';
test('pays with Visa', async ({ page }) => {
await page.goto('/login');
await page.getByLabel('Email').fill('qa@shop.example.com');
await page.getByLabel('Password').fill(process.env.QA_PASSWORD!);
await page.getByRole('button', { name: 'Sign in' }).click();
await page.goto('/catalog/desk-1');
await page.getByRole('button', { name: 'Add to cart' }).click();
await page.goto('/checkout');
await page.getByRole('button', { name: 'Pay now' }).click();
await expect(page.getByText('Order confirmed')).toBeVisible();
});
That file should stay in the PR pipeline, on one or two workers, with traces on first retry. Playwright Trace Viewer is how you debug a single failed pay. Load tools will not replace that replay.
Extract the journey from the test() block
Pull the clicks into a function both Playwright Test and the load runner can import.
import { Page, expect } from '@playwright/test';
export async function payWithVisa(page: Page, email: string, password: string) {
await page.goto('/login', { waitUntil: 'domcontentloaded' });
await page.getByLabel('Email').fill(email);
await page.getByLabel('Password').fill(password);
await page.getByRole('button', { name: 'Sign in' }).click();
await page.goto('/catalog/desk-1', { waitUntil: 'domcontentloaded' });
await page.getByRole('button', { name: 'Add to cart' }).click();
await page.goto('/checkout', { waitUntil: 'domcontentloaded' });
await page.getByRole('button', { name: 'Pay now' }).click();
await expect(page.getByText('Order confirmed')).toBeVisible();
}
The spec becomes a thin wrapper.
import { test } from '@playwright/test';
import { payWithVisa } from '../flows/checkout.journey';
test('pays with Visa', async ({ page }) => {
await payWithVisa(page, 'qa@shop.example.com', process.env.QA_PASSWORD!);
});
Artillery then calls the same function as a testFunction. You keep one journey. You stop asking CI to be the crowd.

The shared qa@shop.example.com cart will collide the moment two browsers overlap. Unique data matters as soon as Playwright load testing overlaps sessions. Key emails off testInfo.testId or testInfo.workerIndex. In a load function you do the same with the VU id the runner gives you.
export function shopperEmail(runId: string, vu: number) {
return `load-${runId}-vu-${vu}@shop.example.com`;
}
Seed those users through the API before the ramp, using Playwright's request fixture or k6 HTTP. Then delete them after. beforeAll create and afterAll delete is enough.
Note: waitUntil: 'networkidle' is a poor default on page.goto. Wait for domcontentloaded or load, then assert the Pay button.
Skip networkidle, keep traces small
Load scripts that record a trace for every VU will drown the generator. Artillery records traces for a small pool of VUs and keeps the ones that fail. Playwright Test's trace: 'on-first-retry' is the CI cousin of that idea.
Do not turn traces on for every canary browser on a long soak. You will measure the recorder. Use Playwright CI reports for the functional shards. Use the load tool's Web Vital stats for the crowd.
When a canary fails, open the trace the same way you open a CI failure. The timeline will show whether Pay waited on /api/pay or on a third-party script.
Sharding stays on the functional side. npx playwright test --shard=1/4 through --shard=4/4 cuts the suite across jobs. Merge blob reports after. Keep that pattern in your CI setup, and leave load generation to k6 or Artillery.
When shards flake under normal CI, treat that as suite health, not load. A Playwright automation checklist still starts workers at 1 and raises them only after the suite is stable.
What to measure when a browser is in the mix
When Playwright load testing includes a real browser, measure the app, then measure the generator. If you only watch server CPU, you will miss a checkout page that paints late. If you only watch LCP, you will miss a pay API that is already returning 500s.
On the protocol side, keep the usual trio: failed-request rate, p95 duration, and throughput. The hybrid sample uses http_req_failed under 1 percent and http_req_duration p95 under 500 ms. Replace those with your SLO.
On the browser side, start with Core Web Vitals. LCP for loading. INP for interactivity. CLS for layout shift. Judge them at the 75th percentile, split by mobile and desktop if you can. A lab Playwright run is not a field panel. It is a canary.
Artillery records LCP and FCP per page the VU visits. k6 browser records browser_web_vital_lcp and browser_web_vital_fcp. Playwright Test does not emit those as load percentiles. A green spec only means the assertion passed inside the timeout.
So add timings in the canary without turning the spec into a benchmark harness.
import { test, expect } from '@playwright/test';
import { payWithVisa } from '../flows/checkout.journey';
test('checkout canary under live APIs', async ({ page }) => {
const email = `canary-${Date.now()}@shop.example.com`;
await payWithVisa(page, email, process.env.QA_PASSWORD!);
const lcp = await page.evaluate(() => {
const entry = performance
.getEntriesByType('paint')
.find((item) => item.name === 'first-contentful-paint');
return entry ? entry.startTime : null;
});
expect(lcp, 'first-contentful-paint should be recorded').not.toBeNull();
});
That snippet reads first-contentful-paint from the Performance API. It is a lab signal. If you need LCP, INP, and CLS the same way Chrome reports them, inject a small vitals helper in the page.
Watch the generator too. If canary LCP jumps when you add protocol VUs, checkout is feeling the load. If canary LCP jumps when you add more Playwright browsers on the same box, you starved the generator. A packed box ruins Playwright load testing numbers the same way it ruins CI.
Learn Playwright in this order if you are new: spec, locators, CI, then this hybrid. Do not start with 5,000 browsers.
When canaries fail only in CI, open the trace before you scale the soak. A missing await, a strict-mode locator, or a third-party script will fail one browser the same way it fails one thousand.
TestDino is a Playwright cloud companion, not a load generator. If canaries fail-then-pass on retry, or flip across runs, its flaky tests view (timing, environment, network, assertion, other) is the triage layer after the soak, not a replacement for k6.
A 5xx from /api/pay in that trace is a product finding. A 30 second goto with no request fired is usually the generator or networkidle again.

Open that pay request before you add VUs. If TTFB is already over your SLO on one browser, a swarm will only amplify it.

If you are still unsure, run the canary with protocol load off, then on. The delta is the product signal. Everything else is the generator.
Conclusion
Steal the journey and leave the runner alone. Keep checkout.spec.ts as the PR gate. Drive volume with protocol VUs. Sit two canary browsers on Pay while that volume is on, and read LCP against your usual good bar.
If --workers=20 is still the plan, run it once on a 2-CPU private ubuntu-latest runner and watch the timeouts. Then delete the flag. The isolated retry pass will usually show the spec was fine.
Next step: extract payWithVisa, run k6 run k6-checkout-hybrid.js against staging with two canary VUs, and compare LCP idle versus LCP at your soak. If the canary only fails when the generator is packed, you do not have a checkout incident yet.
If a canary fails with a real assertion or a 5xx from /api/pay, open the trace and fix that path before you add more VUs.
FAQ

Ayush Mania
Forward Development Engineer