The Real Cost Model of Matrix Builds — How a 4-Axis Matrix Cost $6,400/Month
We started with 3 OS × 3 Node = 9 jobs. Six months later, 4 axes × avg 5 meant 100× the original build time. How to cost matrices up front.
Matrix builds feel almost free. One line, N environments validated. Past four axes, cost explodes multiplicatively.
This post is our cost ledger from a six-month 3 → 4 axes progression.
Start — 3 axes, 9 jobs
matrix:
os: [ubuntu-22.04, ubuntu-24.04, macos-14]
node: [18, 20, 22]3 × 3 = 9 jobs. Expected CI time: 1 job × 4 min × 9 = 36 min total, parallel-8 → ~8 min wall clock.
Pleasing. Every OS × every Node validated in 8 minutes.
Six months later — 4 axes, avg 5, 60 jobs
The matrix grew. Each new requirement added an axis:
matrix:
os: [ubuntu-22.04, ubuntu-24.04, macos-14, windows-2022] # +1
node: [18, 20, 22]
database: [postgres-15, postgres-16, mysql-8] # new axis
region: [us-east-1, eu-west-1] # new axisNow 4 × 3 × 3 × 2 = 72 jobs. Some combos are invalid (Windows + macOS-only DB), so avg 60 actual.
CI time — 5 min per job (DB setup adds time). 60 × 5 = 300 min total, parallel-8 → ~38 min wall clock.
Cost ledger
Initial (3 axes, 9 jobs):
CI time per PR: 8 min
PRs per month: 280
CI minutes per month: 2,240 = 37 hr
GitHub Actions cost: ~$30 / mo
Six months later (4 axes, avg 60 jobs):
CI time per PR: 38 min
PRs per month: 280 (unchanged)
CI minutes per month: 10,640 = 177 hr
GitHub Actions cost: ~$1,800 / mo
Net increase: $1,770 / mo = $21,240 / yrThat's direct cost. Indirect is larger.
Indirect
Extra wait time per PR: 30 min
PRs per month: 280
Engineer wait per month: 8,400 min = 140 hr
Annualized: ~$84,000 (engineer rate)Four times the direct cost. Each axis added means the whole team waits longer.
Decision matrix for adding an axis
Before adding, check:
| Question | Justifies adding? |
|---|---|
| Is there real behavior difference across this combo? | If not — don't add |
| Can the difference be detected at runtime? | If yes — runtime detection instead |
| Does the difference occur less than once a quarter? | If yes — split into a nightly matrix |
| Is the difference critical or minor? | If minor — don't add |
What we did — axis tier separation
Six months in, we split the matrix into three tiers:
1) PR matrix (every PR):
os × node = 9 jobs (8 min)
Purpose: fast feedback
2) main-merge matrix (right after merge):
os × node × database = 27 jobs (15 min)
Purpose: integration validation
3) Nightly matrix (once daily):
os × node × database × region = 60 jobs (38 min)
Purpose: edge-combination validationAfter splitting, PR CI time recovered to 8 min. Monthly cost $1,800 → $400. Indirect cost $84,000 → $14,000.
What matrix builds actually mean
A matrix isn't a tool for validating every combo on every PR. It's a distribution tool for which combos to validate when. Without explicitly designing this distribution upfront, you default to every combo on every PR — which is the cost-explosion path.
So should you add that matrix axis?
Adding a new axis to a CI build matrix is justified only when it passes the four-question decision matrix above. Any team running matrices on 2+ axes that runs the check on every new axis prevents the cost explosion six months out. We skipped it, and only turned back at $1,800/month direct and $84,000/year indirect.
- #matrix-builds
- #cicd
- #cost
- #github-actions
- #infrastructure