r/Firebase • Firebaser • Sep 17 '26

Billing Introducing Firebase spend caps for AI Logic, Functions, and App Hosting

If you’ve spent any time on this subreddit (or building on cloud platforms in general), you know the persistent anxiety around runaway bills from a recursive loop, a viral traffic spike, or an unthrottled API key.

Now, Firebase AI Logic, Cloud Functions for Firebase (1st and 2nd gen), and Firebase App Hosting all let you set spend caps that pause the service after you reach 100% of a configured threshold!

You set spend caps per-service in a single spot in the Firebase console, receive automated email alerts at 50%, 80%, and 100% of a spend cap threshold, see a banner in the console if a service is paused, and can lift spend caps after they're enforced if you need to turn a service back on.

Note that due to latency in usage reporting, spend cap enforcement is not instantaneous and can be delayed by several minutes, and any cost overages incurred during this delay will be billed as normal. Even though they're not instant, spend caps can catch runaway bills much earlier than before.

Spend caps are an emergency circuit breaker, but they work best alongside Budget Alerts, App Check, API key restrictions, and IAM to help avoid surprise bills.

66 Upvotes

34 comments sorted by

21

u/jhuleatt Firebaser Sep 17 '26

Dropping a quick screen recording to show what the spend caps UI looks like:

5

u/neb2357 Sep 17 '26

In your screen recording, those 10s are "$10 USD" I assume? It's not like a percentage or some other weird meaning?

4

u/jhuleatt Firebaser Sep 17 '26

Huh, yes, $10.00. Not sure why it doesn’t show the currency.

2

u/jhuleatt Firebaser Sep 21 '26

Looking closer, it says "Spend cap amounts are specified in USD" above the form. But I'll share this feedback with the console team, since I missed it too!

1

u/jhuleatt Firebaser Oct 26 '26

Update: the Firebase console now shows currency next to the amounts

5

u/Accomplished_Ad_1158 Sep 17 '26

Great! Any plans on something similar for Firestore or RTDB?

6

u/jhuleatt Firebaser Sep 17 '26

Other products are in the works, but we can't give a concrete timeline. Each product needs to be migrated to the special, faster, pipeline that spend caps uses (a bit more about that in my comment here).

In the meantime, a spend cap on functions can at least help with an infinite Firestore or RTDB trigger loop (function triggered on document write, that itself writes to the same document). And, Budget Alerts can notify of billing spikes across the project (although they aren't triggered as quickly as spend caps).

3

u/Accomplished_Ad_1158 Sep 17 '26

Thanks, yes very useful for that part of the risk.

2

u/DimensionHungry95 Sep 18 '26

Ótimo. Esperando por isso.

8

u/indicava Sep 17 '26

Well it’s about god damn time!

jk, great to see Google addressing what is probably the developers community’s biggest concern in using these types of services.

1

u/mr_claw Sep 25 '26

And it only took them 12 years!

1

u/jhuleatt Firebaser Sep 28 '26

Full history of Firebase pricing plans from a long-time Firebaser: https://x.com/_davideast/status/2100706194973147172

4

u/fhinkel-dev Sep 17 '26

How bad can the "few minutes" be? Do you have any anecdotal data? Thanks for finally having spend caps!

6

u/jhuleatt Firebaser Sep 17 '26

In my personal testing I've seen spend cap enforcement time range from just over a minute up to 11 minutes (but YMMV, that's just a couple of tests I've run).

That said, spend caps are much faster (minutes vs hours) than Budget Alerts and billing pub/sub topics thanks to a lot of engineering work that has gone on behind the scenes for the specific products that support spend caps. Instead of waiting for billing data (which takes extra time), the spend caps pipeline predicts overages based on usage.

4

u/ChrisBarnes2000 Sep 17 '26

Good rule of thumb is to set your spend cap to $2 to 20% lower than your actual budget. So say I have $10 per month, either go with a max of $8 or increment each day/week for more granular control. Love the new addition to separate by service or usage type. Now can have dev vs hosting funds properly allocated in my spend cap!

3

u/ChrisBarnes2000 Sep 17 '26

As mentioned in the AI Studio, simple spend cap, they ask for 10m buffer time which falls into your test of 1-11. Think I may have had some blips of 30m delays depending on time zone rollovers or if I start using multiple models and run them all to max. It takes it longer to add them all up. At most it’s only been $1.5 over my cap set. But I’ve also kept them under $10 total.

2

u/jhuleatt Firebaser Sep 17 '26

Thanks for sharing your tips & experience with spend caps!

3

u/fhinkel-dev Sep 18 '26

Thank you!

3

u/leros Sep 17 '26

If you have some sort of crazy fast infinite loop, you can still rack up some spend during a few minutes, but at least its bounded.

3

u/-irx Sep 18 '26 edited Sep 18 '26

How does that differs from regular budget alert + script that will disable the service which works with any firebase service? Without firestore or rtdb it's kinda meh, hopefuly coming soon.

3

u/jhuleatt Firebaser Sep 18 '26

It kicks in significantly faster than that. A bit more background in this comment:  https://www.reddit.com/r/Firebase/comments/1wj2a4e/comment/pafek67/

2

u/Mother-Ad-2559 Sep 18 '26

But nothing for firestore?

2

u/jhuleatt Firebaser Sep 18 '26 edited Sep 18 '26

That's correct. I have a more thorough comment above.

3

u/Dazzling_Matter_8774 Sep 19 '26

That's good but what about firestore and storage?

2

u/22nd_Street Sep 18 '26

Thank you!

2

u/mdeeswrath Sep 19 '26

Love the changes.
Any chance we add this feature for ... you know, firebase itself ( firestore / realtime database )

That would be amazing,

Thank you

2

u/Exotic-Chance-7567 19d ago

About time tbh. Still need proper rate limiting at the edge so a bad actor cant intentionally brick your app by burning through your cap in ten minutes, but as a last resort failsafe this removes so much anxiety.

0

u/ThatPassaGuy Sep 17 '26

if these caps bugs out Google will foot the bill?

4

u/jhuleatt Firebaser Sep 17 '26

Spend cap budgets are available in Preview, which means that it isn't subject to any SLA. Even when they're out of Preview, here's the exact language from the spend cap docs:

Spend caps budgets are not "hard caps". Due to latency in usage reporting, spend cap enforcement is not instantaneous and can be delayed by several minutes. Any cost overages incurred during this delay will be billed as normal. Consider setting your budget slightly below your absolute limit.

All that said, they can greatly reduce the impact of some of the most common mistakes we see (like a Firebase Function that infinitely calls itself).

2

u/MjnMixael Sep 23 '26

well well well. I was just about to start seriously switching to a different platform just so I could have hard limits to protect my bottom line. Guess I'll hang out here for a bit longer, assuming this will come to firestore and storage soon enough.

2

u/[deleted] Sep 24 '26

[removed] — view removed comment

2

u/jhuleatt Firebaser Sep 24 '26

It's still tied to what you've already spent this month, though you can raise the cap's limit. Because you can't edit a cap while it's enforced, you have to lift it first and then increase the limit.

Here's how that looks in practice:

  1. You set a $10 spend cap on Cloud Functions for Firebase.
  2. Your usage hits $10, and the spend cap is enforced (pausing your functions).
  3. You check Cloud Monitoring, see that the usage is legitimate, and decide to turn the service back on.
  4. You lift the spend cap and wait for the Cloud console to show that it has been lifted (a few minutes to an hour).
  5. Your functions are now back up and running with no spend limit for the rest of the month (though the $10 cap will automatically re-enable next month if you don't change anything).
  6. If you still want a cap for the rest of this month, you modify the spend cap to $20 (which only works after the cap has finished lifting).
  7. Your functions continue running under the new $20 cap, with about $10 of budget remaining for the month (since the first $10 still counts).

Thanks for asking this question! I had to go back to the engineering team to make sure I had the details correct, and learned something new about how spend caps work.

1

u/jhuleatt Firebaser Sep 24 '26