lecture 11 of 160 completed

Parallelisation, Cloud, and what runtime costs

Cypress splits work by spec file, and that single fact drives how you organise a suite for speed.

Your pipeline takes forty minutes. Every merge waits for it. Engineers start merging without waiting, and the suite stops being a gate.

Runtime is a budget a senior engineer is accountable for, and reducing it starts with one fact about how Cypress parallelises.

Cypress splits work by spec file, not by test.

That is the whole thing. Ten machines and ten spec files gives you ten-way parallelism. Ten machines and one enormous spec file gives you one machine working and nine idle.

Two consequences follow immediately.

Your slowest spec sets the floor. If one spec takes twelve minutes, no amount of machines gets you under twelve minutes. Splitting that file is the highest-value optimisation available, and it is often the only one needed.

Many small specs beat few large ones. This runs against the instinct to group related tests generously. For parallelism, granularity wins.

How the splitting decides where specs go. Naive splitting is alphabetical or round-robin, which balances badly: one machine gets three slow specs and finishes ten minutes after the others. Cypress Cloud records how long each spec took historically and distributes to balance total time. That is most of what you are paying for.

npx cypress run --record --parallel --key $CYPRESS_RECORD_KEY --ci-build-id $BUILD_ID

--ci-build-id is what groups the machines into one logical run. Get it wrong and each machine thinks it is running alone, executing the whole suite. That mistake produces a pipeline that is slower and more expensive than not parallelising, and it is common enough to be worth checking first when numbers look wrong.

What Cloud gives you beyond load balancing, since teams often evaluate this: run history and flake detection across time, artifacts collected centrally, and the ability to see which spec regressed. The flake detection is the part I would argue hardest for, because it turns "the suite feels unreliable" into a ranked list.

Alternatives exist. Open-source orchestration plugins do the balancing without the subscription. They work. They are also infrastructure you now own and maintain, and that trade should be made deliberately rather than by default in either direction.

The optimisation order, and it matters, because teams usually start at the wrong end:

  1. Find the slow specs. Measure per spec. It is almost always a small number of files.
  2. Split them. Frequently this alone solves the problem.
  3. Cut setup cost. cy.session across specs, API-based arrangement. Usually the second biggest win.
  4. Then add machines. Parallelism multiplies whatever you have. Multiplying a badly balanced suite gives you a badly balanced suite, faster and more expensively.
  5. Then run less. Tiering by risk, which is the next lecture.

Adding machines first is the common mistake because it is the easiest lever to pull. It also costs money every single run, forever, which makes it the most expensive way to avoid a two-hour refactor.

One warning about parallel and shared data. Parallel machines hit the same application and database. Tests that were quietly sharing a record now collide. If your suite has hidden order dependencies, parallelising is what exposes them, and it will look like parallelism made the suite flaky. It did not. It revealed what was already true.

Remember this: Cypress splits by spec file. Split slow specs before buying machines.

Reference: Parallelization.