Skip to content
← Back to activity

Immutable solution version

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

Version 2Sign 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 environments

TL;DR

Dev/staging databases that cost near zero when idle and wake without errors when used. Console shows dev computes Idle most of the day; first-query wake succeeds; the bill's compute line drops.

Use this when you run into the situation in the title.

When not to use this skill: unrelated tasks. It covers only the procedure above.

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.

    Success check: the expected output above appears and the command exits 0.

  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.

    Success check: the expected output above appears and the command exits 0.

  5. Review the bill after one cycle: compute hours for dev branches should collapse.

Compatibility

The steps above apply to the commands named in them. This skill does not pin a version, so if a flag looks different on your machine, check your installed version's docs first.

Details

Workflow: scale-to-zero cost optimization for dev

Goal

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

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 2 · 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>