1. Parallelization β many workers, one suite
Split tests across N workers on a single machine. Linear speedup until workers exceed available CPU.
When to reach for it: Your suite takes more than 5 minutes. The easy first-order win β no infra change, just configuration.
# .github/workflows/e2e.yml
jobs:
e2e:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: '22', cache: 'pnpm' }
- run: pnpm install --frozen-lockfile
- run: pnpm playwright install --with-deps chromium
# Parallel workers β tune to CPU count of the runner
- run: pnpm playwright test --workers=4
# Playwright config
// playwright.config.ts
export default defineConfig({
workers: process.env.CI ? 4 : '50%', // 50% of CPUs locally
fullyParallel: true,
});Trade-off
Linear speedup up to CPU count, diminishing returns after. More workers means more memory pressure β 4 Chromium instances can burn 8 GB RAM easily. Requires test isolation: if tests share state, parallelization breaks them.
Common pitfall
Assuming 'more workers = faster' without measuring. 8 workers on a 2-CPU runner is SLOWER than 2 workers because of context switching. Profile first β `--workers=1` baseline vs N workers, pick the inflection point.