DEV Community

Aleksei Aleinikov
Aleksei Aleinikov

Posted on Originally published at alekseialeinikov.com on

Google Cloud Budget Spend Caps: What They Actually Stop (and What Still Leaks)

Google Cloud Budget Spend Caps: What They Actually Stop (and What Still Leaks)

For nearly a decade, every Google Cloud billing thread ended with the same warning: a GCP budget is an alarm bell, not a circuit breaker. If a runaway AI agent loop, leaked API key, or misconfigured Cloud Run revision burned $4,000 overnight, Google Cloud emailed you politely — and kept billing.

In November 2026, Google Cloud finally moved native Spend Cap Budgets to General Availability in Cloud Billing Budgets. You can now hard-cap monthly usage on eligible services without writing brittle Pub/Sub kill-switches. At the same time, engineers testing the first release quickly noticed sharp boundaries: only 6 services are covered, caps only run on a calendar month, and core infrastructure like GKE and egress can still run uncapped.

Google Cloud Budget Spend Caps: precision circuit breaker halting runaway Cloud Run and Gemini API bills.

The short verdict. Native GCP Spend Caps are a huge win for Gemini API, Cloud Run, and Firebase sandboxes because they pause only the capped service without nuking your entire project. However, they are not an org-wide safety net: you still need API quotas, max-instances, and Pub/Sub alerts for GKE, BigQuery, Cloud SQL, and network egress.

How Native Spend Caps Differ From the Old Pub/Sub Kill-Switch

Previously, enforcing a hard limit in Google Cloud Billing meant wiring budget notifications to a Pub/Sub topic and a Cloud Function that detached the billing account from the project. That pattern had two nasty failure modes: settled billing exports lagged behind spikes by hours, and unlinking billing killed every resource in the project — databases, DNS, and storage included.

Legacy Pub/Sub billing kill-switch vs. native GCP Budget Spend Caps on live estimated gross cost.
Native spend caps pause only the targeted service on live estimated cost instead of unlinking the entire project.

Native spend caps fix the blast radius:

  • Live estimated cost signals: Instead of waiting for finalized invoice rows, spend caps evaluate near-real-time gross estimated costs at list price.
  • Surgical, non-destructive pause: When usage crosses 100% of the cap, Google pauses only new pay-as-you-go requests for that specific service in that specific project. Underlying configuration and data stay intact.
  • Automatic monthly reset (or manual lift): Caps reset on the 1st day of the next calendar month , automatically resuming service — or you can raise or remove the cap anytime in the Cloud Console or API.

Which 6 Services Are Covered (and What Still Leaks)

Here is the exact boundary documented for General Availability — and why developer reaction has been split between “finally!” and “why isn’t X covered yet?”:

Layer / Scope Covered by Native Spend Caps? Details & Caveats
Gemini API Yes Pauses pay-as-you-go token usage once cap hits 100% (Gemini pricing)
Gemini Enterprise Agent Platform Yes Pay-as-on-demand agent/model requests paused at cap
Cloud Run & Cloud Run functions Yes Halts new serverless invocations/revisions (Cloud Run pricing)
Firebase AI Logic & App Hosting Yes Enforced via Gemini / underlying Cloud Run (Firebase billing guide)
Compute Engine, GPUs & GKE No VMs, node pools, and attached disks keep running and billing
BigQuery, Cloud SQL & Cloud Storage No Storage, queries, and managed DB instances remain uncapped
Cloud NAT & Network Egress No Outbound data transfer and NAT traffic are not stopped
CUDs & Provisioned Throughput No Committed Use Discounts and reserved AI capacity bill flat regardless

What GCP Budget Spend Caps cover (6 eligible services) vs. what still leaks (GKE, BigQuery, NAT/egress, CUDs).
Spend caps cover 6 AI and serverless services per project, while core compute, storage, egress, and commitments remain uncapped.

Five Limitations Engineers Are Flagging

Before relying on a spend cap in production or client sandboxes, account for five strict rules in the Cloud Billing Budget REST API:

  1. One project, one service per cap. You cannot create a single spend cap across a folder, an organization, or a whole billing account. Every project + service pair needs its own budget resource.
  2. Calendar month only (MONTH). There are no hourly, daily, or rolling 24-hour spend caps yet. If a bug burns your entire monthly $200 cap on November 2, the service stays paused until December 1 unless you manually lift it.
  3. Mandatory EXCLUDE_ALL_CREDITS. Spend caps measure gross list-price usage, ignoring promotional credits and negotiated discounts. Any API request with spendCap.enabled: true fails validation unless creditTypesTreatment is explicitly set to EXCLUDE_ALL_CREDITS.
  4. No IAM-level or per-API-key caps inside the budget. You cannot cap “User A” or “Staging key B” inside one project — isolation still requires separate GCP projects per environment or tenant.
  5. Small ingestion lag still exists. Under a sudden burst of parallel requests, telemetry lag can let actual spend creep slightly above 100% before enforcement kicks in. Always set the cap at 80–90% of your hard ceiling.

API Configuration: Creating a Spend Cap via Budget API

If you provision sandbox or AI projects with Terraform or CI pipelines, attach a spend cap right at project creation using the Budget API:

{ "displayName": "sandbox-gemini-spend-cap", "budgetFilter": { "projects": ["projects/my-ai-sandbox-123"], "services": ["services/gemini-api-service-id"], "creditTypesTreatment": "EXCLUDE_ALL_CREDITS", "calendarPeriod": "MONTH" }, "amount": { "specifiedAmount": { "currencyCode": "USD", "units": "100" } }, "spendCap": { "enabled": true }}
Enter fullscreen mode Exit fullscreen mode

Warning

Don’t put a hard spend cap on customer-facing production without a fallback. Because a triggered cap immediately pauses incoming traffic for that service, hard caps belong on dev/sandbox projects, student/hackathon accounts, and non-critical internal AI tools. On revenue-generating production services, use alert-only budgets + rate limits instead so a $100 spike doesn’t become a self-inflicted outage.

The Production 3-Layer Defense Stack

Native spend caps work best as one layer inside a broader cloud cost optimization setup, not as a replacement for architecture hygiene:

  1. Layer 1 — Native Spend Caps on AI & Serverless: Put per-project monthly spend caps on Gemini API, Cloud Run, and Firebase in all non-production and experimental projects at 80–90% of your max tolerance.
  2. Layer 2 — Service Quotas & Concurrency Limits: Cap Cloud Run --max-instances and --concurrency, set Vertex/Gemini requests-per-minute quotas, and enforce BigQuery maximum_bytes_billed per query so a single bad loop stalls at the API boundary in seconds.
  3. Layer 3 — Pub/Sub Alerts for Uncapped Infra: Keep alert-only budgets (50%, 80%, 100%) wired to Slack/PagerDuty for GKE, Compute Engine, Cloud SQL, and egress — and isolate untrusted experiments in dedicated projects so a billing alert never threatens core databases.

The Bottom Line

Google Cloud’s native Budget Spend Caps finally solve the #1 hobbyist and AI-prototype nightmare: waking up to a four-figure Gemini or Cloud Run invoice with zero circuit breaker. Just don’t mistake a 6-service, single-project monthly cap for full-account protection — keep quotas on your APIs, caps on your sandboxes, and alerts on everything else.

Sources

Originally published at alekseialeinikov.com

Top comments (0)