- All playbooks
- Slow tests
- Isolate state before running tests in parallel
Isolate state before running tests in parallel
Give concurrent tests independent databases, services, or fixtures so they can share runner capacity without interfering with each other.
How companies used this technique
Read what each company changed and follow the original sources.
Run isolated end-to-end journeys in parallel
The packaged end-to-end suite ran 66 journeys on one worker. Each journey already had its own home directory, workspace, runtime and server port, so the PR set Playwright to three workers with fullyParallel. Global setup sweeps orphaned processes once and installs the Electron runtime once, before any worker starts.
- Use it when
- A browser or desktop suite runs on one worker while its tests share no files, ports or processes.
- Before applying it
- Parallel journeys are safe when each owns its state; a shared file, port or install step becomes a race. Measure the worker count on your own runner.
Give parallel test workers more databases
After the CPU change, raising the pytest-xdist worker count left the suite's time flat at first. Profiling showed the test database buckling under the load: it hit lock contention once more than 20 workers shared it. Ramp ran more test databases, measured the ratio of workers to databases, settled on about 12 workers per database, and tuned Postgres connection settings.
Together with the faster CPUs, the database changes took Ramp to a ~70% speedup of the test suite two days in, a saving of about 30 minutes. Source
- Use it when
- Tests run in parallel workers against one shared database or service, and adding workers leaves the job's time flat while the database is saturated.
- Before applying it
- Every extra database uses CPU and memory the test workers would otherwise get; Ramp saw slight regressions past its measured ratio, so keep the count that measured fastest.
Isolate tests before adding workers
The CLI end-to-end suite shared one development store. Shopify/cli#7279 gave each test its own store and each worker its own ports; #7309 then turned on fullyParallel and raised Playwright workers from one to five. The default branch runs the suite fully parallel with four workers.
The PR reports about 10 minutes with 5 workers, down from about 27 minutes with 1 worker. Source
- Use it when
- Tests run one at a time because they share ports, temporary files, accounts or database state.
- Before applying it
- More workers add load on shared external APIs; keep teardown observable and keep genuinely serial tests on a serial lane.
Give concurrent tests their own state
Stripe sync-engine gives each end-to-end test file its own Postgres container on a random port and enables file parallelism; webhook tests run in a separate sequential configuration because they share a remote endpoint. TaxJar, a Stripe company, made its remote transaction IDs unique per version and build so its WooCommerce 7.x and 9.x test lanes can run in parallel.
- Use it when
- A shared database, port or remote account forces the whole suite to run serially.
- Before applying it
- Keep intentionally shared-state tests in a serial lane, keep teardown reliable, and use isolated sandbox accounts for remote services.
Give concurrent suites their own services
SubmitQueue replaced shared manual service setup with a Compose stack per test context. Docker allocates an ephemeral host port and the test discovers it at runtime, so the suites run as separate parallel CI jobs. OPT88's resource-isolation step is adapted; the readiness and image-tag fixes on this page complete it.
The PR creates separate CI jobs for the suites and an isolated Compose project per test context. Source
- Use it when
- Independent integration suites collide on one port, database or container name, forcing serial execution.
- Before applying it
- Use collision-proof namespaces and guaranteed cleanup after every run. Separate data and image tags as well as ports, and use a protocol-level readiness probe in place of a fixed startup sleep.
Company Playbooks
- Read Anthropic’s playbookRun only affected tests
- Read DoorDash’s playbookRun build and test in parallel, sharded across CI agents
- Read Linear’s playbookBenchmark the same job on faster hardware
- Read Mastra’s playbookStarSling runners for the slowest test workflow
- Read OpenAI’s playbookRank CI fixes by the minutes they save
- Read Ramp’s playbookMove a CPU-bound test suite to a faster CPU
- Read Shopify’s playbookLet an agent iterate against one CI metric
- Read Spotify’s playbookBuild arm64 on native arm64 runners
- Read Stripe’s playbookRun only the tests a change can reach
- Read Uber’s playbookBuild the merge-queue speculations most likely to be needed