Firebase billing
Can you set a spending limit on Firebase?
Firebase's Blaze plan has no spending limit for the whole project: budget alerts don't cap usage, and spend caps pause only 4 services (Firebase AI Logic, App Hosting, Cloud Functions for Firebase and Firebase Extensions) once one hits 100% of its monthly budget. Cloud Firestore, Realtime Database, Cloud Storage and Hosting can't be capped; the only full stop for them is a function that disables billing on the project.
Spend caps aren't instant either. Firebase says enforcement can be delayed by several minutes, and the overage is billed.
Every way to limit Firebase spend
| Option | What happens at the limit | Products it covers | The catch |
|---|---|---|---|
| Spark plan | The product shuts off for the rest of the month | Every product on Spark | No App Hosting, Cloud Run or Pub/Sub; linking a billing account moves you to Blaze |
| Alerts-only budget | Emails; nothing is paused | Any | Budget alerts don't cap usage or charges |
| Spend cap budget | New usage of one service pauses for the rest of the month | AI Logic, App Hosting, Cloud Functions, Extensions | Can lag several minutes; overage billed; one service per project |
| Function that disables billing | Billing is removed and every service in the project shuts down | Everything in the project | Resources might be irretrievably deleted; notifications about every 20 minutes |
| Costbrake | Alerts; an admin can add a zero spend cap to one service | Alerts on all; brakes on the 4 cappable services | Firestore, Realtime Database, Storage and Hosting arrive with the billing export, typically within a day |
Spend caps: the four services you can cap
A spend cap is a Cloud Billing budget that pauses one service in one project. Firebase maps its products onto the Google Cloud service underneath:
- Firebase AI Logic: caps the Gemini Developer API or the Agent Platform Gemini API (formerly Vertex AI).
- Firebase App Hosting: caps the Cloud Run service it runs on.
- Cloud Functions for Firebase: caps Cloud Run functions.
- Firebase Extensions: also caps Cloud Run functions.
Each cap runs on a monthly budget. Cloud Billing sends warning emails at 50% and 80%. At 100% it enforces the cap: new usage of that service pauses for the rest of the month, and your app starts getting errors for it. You can lift the cap to resume, though some services take up to an hour to come back, or wait for it to reset at the start of the next month. The cap counts gross cost, before savings and credits, and it applies to every use of the service in the project, not only calls made through Firebase.
It isn't a hard cap. Firebase says enforcement can be delayed by several minutes and any overage in that time is billed, so set the budget slightly below your real limit. Google says caps on AI services trigger within minutes, using estimated live costs.
What you can't cap: Firestore, Realtime Database, Storage and Hosting
On Blaze these products bill pay as you go past their no-cost quotas, and none of them has a spend cap yet; Firebase says it is working to add more services. Blaze includes 50,000 Firestore document reads and 20,000 writes a day at no cost. Past that, every read and write is charged.
Firebase names two common causes of a runaway bill: a database query with no limit on millions of results, and Cloud Functions that fan out or loop forever. It recommends testing against the Local Emulator Suite first. Firestore and Cloud Storage usage is calculated daily and Cloud Functions monthly, so check the Usage and billing dashboard often. More on the usual causes in how to avoid a surprise Firebase bill.
The full stop: a function that disables billing
Google documents one way to stop everything. Create a budget, connect a Pub/Sub topic to it, and deploy a Cloud Run function that compares costAmount with budgetAmount on each message and removes the billing account from the project through the Cloud Billing API. Google's sample grants the function's service account the Billing Account Administrator role on the billing account.
Read Google's warning first: removing billing shuts down all resources, including Free Tier services, resources might be irretrievably deleted, and turning billing back on needs manual setup with no guarantee your services recover. It isn't exact either. Billing notifications arrive about once every 20 minutes, Google says the setup doesn't guarantee you stay under budget, and it can't remove billing from a project that is locked to a billing account.
For a hobby project with nothing to lose, that's a fair last resort. For an app with user data in Firestore or Storage, a deleted database costs more than the bill.
Where Costbrake fits
Costbrake's Google Cloud integration reads your Cloud Billing export in BigQuery, which covers every Firebase product on the billing account. Google says Firebase reports usage at varying intervals and cost details typically arrive within a day, so Firestore, Realtime Database, Storage and Hosting spend shows up in Costbrake that late.
For the Gemini API, Vertex AI, Cloud Run and Cloud Run functions, the services behind Firebase's four spend caps, Costbrake also reads live usage from Cloud Monitoring in up to 8 projects. Pro checks every 5 minutes, and every 2 minutes during a spike, and alerts on spikes, budgets and forecasts by email, Slack, Discord or webhook.
Its Google Cloud brake sets a zero spend cap on one of those services in one project, and only after an admin clicks and confirms. Google then pauses new usage once its estimate passes the cap; that isn't instant, and usage until then is billed. Undo lifts the cap, and Google can take up to an hour to let usage through again. Costbrake never disables billing, so nothing is deleted. It has no brake for Firestore, Realtime Database, Storage or Hosting, because Google offers no cap for them. Free covers 2 connections with hourly checks; see pricing.
Questions and answers
Does Firebase have a spending limit?
Not for a whole Blaze project. Budget alerts only send emails, and spend caps pause just four services: Firebase AI Logic, App Hosting, Cloud Functions for Firebase and Firebase Extensions. The Spark plan is the only hard limit: a product shuts off for the rest of the month once it passes its no-cost quota.
Can I cap Cloud Firestore costs on the Blaze plan?
No. Cloud Firestore has no spend cap, so it bills pay as you go past its daily no-cost quota of 50,000 reads and 20,000 writes. The only way to force a stop is a budget notification that triggers a function to disable billing on the whole project, which Google warns can delete resources.
Do Firebase budget alerts stop charges?
No. Firebase says budget alerts don't cap your usage or charges and don't pause services; they email you at the thresholds you set. To pause a service you need a spend cap budget, which only exists for four Firebase services.
What happens when a Firebase spend cap is enforced?
At 100% of the monthly budget, new usage of that service is paused for the rest of the month and your app gets errors for it. Usage in the minutes before enforcement is still billed. You can lift the cap to resume, which can take up to an hour, or it resets at the start of the next month.
Is it safe to disable billing automatically when my Firebase budget is hit?
Only if you can lose the project's data. Google warns that removing billing shuts down all resources, resources might be irretrievably deleted, and recovery isn't guaranteed. Billing notifications arrive about every 20 minutes, so you can still go over budget before the function runs.
Sources
- Firebase pricing plans
- Avoid surprise bills - Firebase
- Set up spend caps for Firebase services
- Advanced billing alerts and logic - Firebase
- Understand App Hosting costs - Firebase
- Disable billing usage with notifications - Google Cloud
- Spend caps - Google Cloud Billing
- Structure of Standard data export - Google Cloud
- Google Cloud spend caps now generally available
Updated