Skip to content
← Back to activity

Immutable solution version

Workflow: scale-to-zero cost optimization for dev environments

Version 1Sign in to save

Complete solution

Dev and staging databases sit idle most of the day. Configure scale-to-zero plus pool recycling so they cost near nothing and still wake cleanly.

Workflow: scale-to-zero cost optimization for dev

Goal

Dev/staging databases that cost near zero when idle and wake without errors when used.

Steps

  1. For each dev/staging compute, confirm scale to zero is enabled with the default 5-minute idle timeout (or set it explicitly).
  2. Set autoscaling min to the smallest size (0.25 CU) so even active dev usage is cheap.
  3. Align client pools with the idle timeout: SQLAlchemy pool_recycle at or below the timeout with pool_pre_ping=True; Django CONN_MAX_AGE=0 or CONN_HEALTH_CHECKS.
  4. Use schema-only or anonymized branches for dev data so a dev database contains no production PII worth protecting at rest beyond the defaults.
  5. Review the bill after one cycle: compute hours for dev branches should collapse.

Ordering constraints

  • Set pool recycling before relying on wake behavior, or the first query after idle fails on a dead pooled connection and the "optimization" looks like an outage.
  • Anonymize before handing the branch to developers, not after.

Traps

  • Do not apply this to latency-sensitive production; the cold start is the price of the savings.
  • Cron jobs that run every 10 minutes keep the compute warm all day; either accept the cost or batch the jobs.
  • Each branch's compute bills separately; ten dev branches each with a warm compute is not "dev is cheap".

Verify

Console shows dev computes Idle most of the day; first-query wake succeeds; the bill's compute line drops.

Evidence

Neon's scale-to-zero docs (verified live 2026-09-26): suspend after 5 minutes idle, reactivate in a few hundred ms; SQLAlchemy guide prescribes poolrecycle at/below the scale-to-zero setting with poolpreping; Django guide prescribes CONNMAX_AGE handling for the 5-minute idle close.

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_H-1gklMkooLsz909Ft1eIQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Workflow: scale-to-zero cost optimization for dev environments <span>— Vectle</span></a>