Skip to main contentClaim $5 in free credit — one-time, per account. Claim $5 free
Krova CloudKrova Cloud
AI Code Sandboxing

Preview Environments per Pull Request, Done Cheaply

A preview environment per pull request catches integration drift early. The hard part is lifecycle: creation cost, TTLs, data seeding and teardown.

4 min read
Share
Preview Environments per Pull Request, Done Cheaply

Preview Environments per Pull Request, Done Cheaply

Preview environments turn a pull request from a diff into a running system a reviewer can click. Teams abandon them for one reason: lifecycle debt. Orphaned environments, stale seed data and surprise invoices kill the practice faster than any technical flaw. This guide designs the lifecycle first and treats the environment itself as the easy part.

Why per-PR still wins

Integration drift hides in the gap between "tests pass" and "works with everything else". A preview environment closes that gap at the moment a human is already paying attention. GitHub's own documentation treats review workflows as the place where integration feedback belongs, and ephemeral compute now makes the marginal cost of that feedback small. We checked E2B's per-second rates and Fly's learn pages while costing the design below. The environment itself is rarely the expensive line.

The lifecycle contract

  1. Create on pull request open, not on every push; reuse the same environment across pushes.
  2. Label everything: pr number, commit sha, owner, creation time. Unlabelled boxes become orphans.
  3. Seed with a deterministic fixture, never with production dumps.
  4. Set a hard time-to-live with auto-destroy on merge or close, plus a sweep for orphans.
  5. Post the URL and the destroy-by time back into the pull request thread.

Labels deserve special emphasis, because every orphan we have ever heard about started as an unlabelled box created by a script nobody owns. A label costs nothing and makes the sweep trivial. Ownership without labels is a policy document waiting to fail.

That contract is the whole game. Teams that skip step four end up paying for zombies, exactly the failure mode we describe in why teams need ephemeral environments now.

Cost ceiling math

Model it before you build it. Concurrency equals open pull requests in a busy hour; duration equals review latency plus TTL slack; price equals your platform's per-minute or per-second rate. Twenty open requests at two vCPU for three hours each, on a $0.0504 per vCPU-hour meter, is about six dollars a day. Halve the TTL and you halve the bill without touching review quality, because most previews are visited in the first hour. This is the same arithmetic as speeding CI with microVMs, applied to human latency instead of job latency.

Making reviewers actually use them

A preview nobody clicks is pure cost. Put the URL in the first comment, keep cold start under the time a reviewer spends reading the diff, and warm your dependency cache so creation feels instant. Snapshot-based restore, as covered in our cloud development environments roundup, is what makes the second and later pushes fast.

When previews are the wrong tool

Some repositories do not earn a preview environment. Pure infrastructure-as-code changes, documentation edits and dependency bumps with green CI add cost without adding feedback. Route those straight to merge checks and keep previews for changes that alter running behaviour.

Monorepos need scoping too: build previews only for affected services, or the concurrency model collapses under its own width. Affected-path detection is a solved problem; ignoring it is not.

Verdict

Build the teardown before the creation path. A preview environment programme with a hard TTL, labels and an orphan sweep pays for itself in caught drift; the same programme without teardown becomes a budget incident and gets cancelled.

Limitations

  • Cost figures are a model from public rate cards read on 22 October 2026, but they are not your invoice.
  • Review latency varies by team; however, it drives duration more than any technical choice does.
  • We cannot claim measured click-through here; the usage advice is design reasoning, not data.
  • Seeding constraints differ per stack, so fixture cost is excluded from the model.

FAQ

Should every pull request get a preview environment?

Every pull request that touches running behaviour. Documentation-only and pure refactor changes can skip it without losing much.

What TTL works in practice?

Start at 24 hours with destroy-on-close, then tighten after reading your visit logs. Most reviews happen within the first hour.

How do we stop orphaned environments?

Labels plus a scheduled sweep that destroys anything unlabelled or past TTL. Automation, not policy documents.

{
  "@context": "https://schema.org",
  "@graph": [
    {
      "@type": "BlogPosting",
      "headline": "Preview Environments per Pull Request, Done Cheaply",
      "datePublished": "2026-10-23",
      "dateModified": "2026-10-23",
      "author": {"@type": "Organization", "name": "Krova Cloud Engineering"},
      "publisher": {"@type": "Organization", "name": "Krova Cloud"},
      "mainEntityOfPage": "https://krova.cloud/blog/preview-environments-per-pull-request-guide"
    },
    {
      "@type": "FAQPage",
      "mainEntity": [
        {
          "@type": "Question",
          "name": "Should every pull request get a preview environment?",
          "acceptedAnswer": {"@type": "Answer", "text": "Every pull request that touches running behaviour. Documentation-only and pure refactor changes can skip it without losing much."}
        },
        {
          "@type": "Question",
          "name": "What TTL works in practice?",
          "acceptedAnswer": {"@type": "Answer", "text": "Start at 24 hours with destroy-on-close, then tighten after reading your visit logs. Most reviews happen within the first hour."}
        },
        {
          "@type": "Question",
          "name": "How do we stop orphaned environments?",
          "acceptedAnswer": {"@type": "Answer", "text": "Labels plus a scheduled sweep that destroys anything unlabelled or past TTL. Automation, not policy documents."}
        }
      ]
    }
  ]
}
For AI agents:llms.txtsitemap

Related posts