GuidesSpeed up your suite

Optimize test load

Find the right balance between speed and reliability when parallel test runs hit staging, local server, or downstream limits.

Running 50 to 500 browsers at the same time is what makes Endform fast. It also sends far more concurrent traffic to your app, database, and third-party APIs than a handful of local or CI workers ever did.

The goal is not unlimited concurrency at any cost. It is finding the fastest concurrency your stack handles reliably, and scoping limits narrowly so a single bottleneck does not slow down the rest of your suite.

Balance speed and reliability under parallel load

As you increase how many tests run at once, total suite duration drops steeply until a backend server, database connection pool, or rate-limited third-party service saturates. Past that inflection point, requests queue up, response latency spikes, and tests start failing with timeouts, HTTP 429 rate limits, or 503 errors. Retries pile even more traffic onto an already overloaded server, making runs both flakier and slower.

Chart plotting suite run time against concurrent tests: run time drops steeply until the backend saturates, then climbs back up as queueing, retries, and 429 or 503 timeouts kick in. A dashed target zone marks where concurrentTestLimits keeps runs fast and reliable.

A load bottleneck is usually easy to spot: tests pass cleanly on their own, then suddenly start timing out or returning 429 or 503 errors once you run the full suite at once. If a test is already slow when running alone because of heavy UI setup or chained flows, start with Fully parallel testing first.

Protect your staging setup

The first question to answer for any parallel suite is practical: what is your staging setup like, and does it fall over straight away under concurrent traffic?

Many teams run tests against a single small staging container or a shared database with a tight connection limit. If a full Endform run saturates staging right out of the gate, start with a suite-wide guardrail in endform.config.ts so runs stay green immediately:

endform.config.ts
import { defineEndformConfig } from "endform";

export default defineEndformConfig({
  concurrentTestLimits: [
    { scope: "within-suite-run", limit: 30 },
  ],
});

If multiple pull request pipelines share the same staging environment, a per-run cap is not enough on its own: five developers pushing at the same time still multiply load by five. Use scope: "across-all-runs" to share one global concurrency budget across every matching run in your organization:

endform.config.ts
import { defineEndformConfig } from "endform";

export default defineEndformConfig({
  concurrentTestLimits: [
    { scope: "within-suite-run", limit: 30 },
    { scope: "across-all-runs", limit: 40 },
  ],
});

A cap keeps a constrained staging server stable today. Longer term, if your staging server can only serve 10 concurrent users, the best speedup is moving PR checks onto dedicated ephemeral or preview environments (such as Vercel previews or Netlify Deploy Previews) so each pull request scales independently.

Isolate slow or rate-limited downstream services

When only a slice of your tests hits a bottleneck, cap the bottleneck rather than the whole suite.

Suppose 4 out of 20 tests hit a payment sandbox, an auth provider with strict rate limits, or an external email API that only handles 2 requests at a time. Putting a whole-suite cap of limit: 2 forces all 20 tests into 10 slow waves. Scoping limit: 2 to just the 4 payment tests lets the other 16 tests fan out immediately while the 4 payment tests queue cleanly 2 by 2.

Gantt comparison of 20 tests where 4 are tagged @payments: a whole-suite limit of 2 forces all 20 tests into 10 slow waves, whereas a targeted tag:@payments limit of 2 lets the other 16 tests finish immediately while only the 4 payment tests run in 2 waves.

Endform supports three targeted selectors in concurrentTestLimits:

1. Tag-specific limits (tag:)

In BikeBook's slow deployment (DEMO_PROFILE=slow), the payment provider processes at most 2 charges at a time (PAYMENT_PROVIDER_CONCURRENCY = 2). In suites/04b-speed-optimized, the checkout upgrade tests carry { tag: "@payments" }:

suites/04b-speed-optimized/tests/billing.spec.ts (excerpt)
testWithNewUser.describe("upgrading", { tag: "@payments" }, () => {
  testWithNewUser("upgrading to Base starts a subscription", async ({ page }) => {
    await purchase(page, "Base");
    await expect(page.getByText("Current Plan: Base")).toBeVisible();
  });

  // ...other checkout tests
});

Then endform.config.ts caps only @payments tests to 2 at a time while the other 17 tests run unconstrained:

suites/04b-speed-optimized/endform.config.ts
import { defineEndformConfig } from "endform";

export default defineEndformConfig({
  proxyNetworkHosts: ["<loopback>"],
  concurrentTestLimits: [
    { scope: "within-suite-run", label: "tag:@payments", limit: 2 },
  ],
});

Here is the live run of suites/04b-speed-optimized against BikeBook's slow deployment, finishing all 20 tests in about 40 seconds while keeping the @payments tests smoothly within the 2-charge ceiling:

20 tests · slow app

2. Project-specific limits (project:)

If one Playwright project targets a heavier backend or a specific microservice that handles less traffic than the rest of your app, scope a limit by project name:

endform.config.ts
concurrentTestLimits: [
  { scope: "within-suite-run", label: "project:billing-service", limit: 8 },
],

3. Playwright native test locks (lock:)

Playwright's native test locks work across Endform's remote machines out of the box. Any tests sharing a lock (for example, test.describe.configure({ lock: "payments" })) automatically run one at a time (limit: 1) within a suite run.

When a locked resource can handle more than one concurrent test, or needs to be shared across concurrent CI runs, add a lock: rule in endform.config.ts to override the default:

endform.config.ts
concurrentTestLimits: [
  // Allow up to 2 tests holding the "payments" lock across all concurrent runs
  { scope: "across-all-runs", label: "lock:payments", limit: 2 },
],

Stacking rules and tuning limits

When multiple concurrentTestLimits rules match a test, the test starts only when every matching rule has capacity. To find the right number for a service:

  1. Start near the service's known capacity (or half the concurrency where failures began).
  2. Run the tagged tests with --repeat-each=3 on Endform and inspect both pass rate and individual test duration.
  3. Step the limit up until p95 test duration starts climbing or 429/503 errors appear, then step back one notch into the target zone.

Local and CI-hosted servers: run production builds

When Endform runs against a server hosted on your laptop or inside a CI job (via Playwright webServer or proxyNetworkHosts), every remote browser sends traffic to that single machine over Endform's encrypted tunnel.

Two settings make the biggest difference for local and CI-hosted servers:

  • Run a production build in CI, not a dev server. Development servers (next dev, vite, webpack dev servers) compile routes on demand, run file watchers, and stall quickly when 20 browsers hit fresh routes at the same instant. In CI, build once and serve the production bundle:

    playwright.config.ts
    export default defineConfig({
      webServer: {
        command: process.env.CI
          ? "npm run build && npm run start"
          : "npm run dev",
        url: "http://localhost:3000",
        reuseExistingServer: !process.env.CI,
      },
    });
  • Adjust concurrentTestLimits for local dev runs vs. CI. Because endform.config.ts is TypeScript, you can cap local runs against a dev server (around 5 to 10 tests at once) while giving CI production builds more headroom (or removing the cap in CI altogether if CI runs against a deployed preview):

    endform.config.ts
    import { defineEndformConfig } from "endform";
    
    export default defineEndformConfig({
      concurrentTestLimits: [
        // Cap local dev servers to 8; allow 15 against a CI production build
        { scope: "within-suite-run", limit: process.env.CI ? 15 : 8 },
      ],
    });

See Test against a local server for full tunnel setup (webServer, proxyNetworkHosts, proxyNetworkPorts) and when to move to a deployed preview instead.

Check your runner region

By default, Endform picks "us" or "eu" automatically based on where the CLI runs. That works well when your app lives in the same region as your laptop or CI runner, and can add unnecessary latency when they do not.

The most common mismatch is GitHub Actions running in the US while your staging app and database live in Europe. With the default region, every single browser navigation, asset load, and API call crosses the Atlantic.

Set region in endform.config.ts to match where your app and database are hosted:

endform.config.ts
import { defineEndformConfig } from "endform";

export default defineEndformConfig({
  region: "eu",
});

Now only the single CLI test-bundle upload crosses regions, while every browser round-trip stays local to your app.

Putting it together

A production endform.config.ts combines only the rules that correspond to real constraints you observed in your stack:

endform.config.ts
import { defineEndformConfig } from "endform";

export default defineEndformConfig({
  // Match where your staging/preview app and database live
  region: "eu",

  concurrentTestLimits: [
    // Keep any single run from saturating a modest staging server
    { scope: "within-suite-run", limit: 30 },
    // Protect a shared 2-slot payment sandbox without slowing other tests
    { scope: "across-all-runs", label: "tag:@payments", limit: 2 },
    // Cap total write load when multiple PR pipelines share staging
    { scope: "across-all-runs", label: "tag:@writes-to-staging", limit: 25 },
  ],
});

Start with no limits on a healthy deployed preview, measure where your stack's inflection point sits, and add targeted limits only where they keep runs both fast and green.

Last updated