Skip to content
Latchkey

How to Use a Larger Runner for Test Parallelism

A larger runner speeds a test suite only if the runner parallelizes across its cores; otherwise sharding across several standard runners is usually cheaper for the same speed.

You have two ways to parallelize tests: one big runner with many cores, or many standard runners each running a shard. The right choice depends on which your test runner supports and which costs less for your suite.

One larger runner, many workers

.github/workflows/ci.yml
jobs:
  test:
    runs-on: ubuntu-latest-8-cores
    steps:
      - uses: actions/checkout@v4
      - run: npm ci
      - run: npx jest --maxWorkers=8   # use all cores on one runner

Or shard across standard runners

.github/workflows/ci.yml
jobs:
  test:
    strategy:
      matrix:
        shard: [1, 2, 3, 4]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm ci
      - run: npx jest --shard=${{ matrix.shard }}/4

Which is cheaper

Four standard runners bill at 4x the standard rate together, similar to one 8-core runner at ~4x. Sharding wins when each shard fits a small runner and startup is cheap; a single larger runner wins when tests share expensive fixtures or the runner cannot shard. Benchmark both.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →