One Environment Per PR — Twelve Months of Real Cost

The decision to spin up an ephemeral environment per PR is *seductive*. Twelve months of measured cost showed *the bill wasn't where the cost lived*.

John Baek
John Baek
Founder, CollabOps
One Environment Per PR — Twelve Months of Real Cost

Last January we decided to spin up an ephemeral environment per PR. Twelve months in, we have the real cost table.

The cloud bill was less than expected. The other costs were more than expected.

Cloud bill — less than expected

Avg env lifetime per PR:   2.4 hrs (between PR open / first commit / merge)
Avg PRs per week:          62
Env-hours per month:       ~6,500
EC2 (small):               $0.05 / hr × 6,500 = $325
RDS (Aurora serverless):   $180
EBS:                       $90
Network:                   $40
─────────────────────────────────
Total bill:                $635 / mo = $7,620 / yr

Actual 12-month spend: $8,400. +10% vs plan. Numerically clean.

The cost off-bill

This is where the truth begins.

1. Engineer time lost to boot

Average env boot time 4 min 12 sec per PR. Engineers wait during that. Over a year:

3,224 PRs × 4.2 min = 13,540 min = 225 hours = ~$22,500 (engineer rate)

Three times the cloud bill. The single most expensive line.

2. Environments that don't get cleaned up

In theory: auto-deletion on PR merge. In practice: 14% fail to auto-delete for some reason. Quarterly manual cleanup removes about 60 orphaned envs.

Annual orphan cost — about $1,200 (negligible but not zero).

3. Managing DB seed data

Each ephemeral env needs DB seed. We started with an anonymized snapshot of production. Six months in we discovered seed staleness — new schemas added, seed not updated. PRs passed in env, broke production with schema mismatch. Two incidents.

Fix — seed auto-refresh pipeline + seed schema validation tooling. Two-week build. Then quarterly check.

4. Handling external dependencies

How do ephemeral envs connect to external APIs (Stripe, SendGrid, etc.)? Two options:

  • Shared sandbox credentials — all envs share one sandbox. Concurrency issues possible.
  • Per-env sandbox — call vendor API for new sandbox, hits vendor-side quota.

Our choice: shared sandbox + test-isolation namespace. Not clean, but works.

5. Cleanup monitoring

Auto-cleanup must run without silent failures. Failure → bill grows. We added a cleanup success-rate dashboard. Quarterly check.

Is it worth adopting?

Annual cloud bill:                 $8,400
Annual engineer boot wait:         $22,500
Annual orphan envs:                $1,200
Annual extra infrastructure ops:   $4,800
────────────────────────────────────
Annual total cost:                 $36,900

Annual savings (hypothesized):
  - Faster PR review:              $25,000 (qualitative)
  - Fewer regression incidents:    $15,000 (estimated)
  - Shorter QA cycles:             $10,000
  ─────────────────────────
  Annual saving:                   $50,000

Net value about $13,000 / yr. Small but positive.

The real point isn't that the net is positive. It's that engineer boot wait at $22,500 is the largest line — and it can be cut directly by reducing boot time. Drop boot from 4 min to 1 min and annual cost drops by $15,000, raising net value to $28,000.

Four checks before adopting

  1. Is there an auto-refreshing seed data pipeline?
  2. Is there an external-dependency sandbox policy?
  3. Is auto-cleanup failure handling automated?
  4. Is there an explicit boot-time target (typically under 90 seconds)?

Without these four, every cost line above grows 1.5–2×.

For platform leads evaluating ephemeral environments, the takeaway is simple. If any of these four are missing, build them before adoption — that's what halves the total cost.

Tags#ephemeral-environments#cicd#cost#devops#infrastructure