Is there a way to limit Firebase's Blaze plan?

18,910

Solution 1

Every Firebase project is also a Google Cloud Platform project. This means that many of the advanced features of Google Cloud Platform are also available for your Firebase project.

For example, you can set up billing alert for your Firebase project, so that you are alerted when the usage reaches a certain level. While you can't configure it to switch off the project at some point, the alert should typically be quite good for alerting you to unusual usage patterns.

For more on this see:

The GCP documentation now also has a section on capping (disabling) billing to stop usage. This is a brute force approach though and may lead to data being lost, so I'd recommend investigating all other options first.


Update (December 2020): Firebase's Todd Kerpelman just released a series of videos where he disables billing using the process from the documentation mentioned above.

Solution 2

You cannot set spending limits to your app now.

As of December 12, 2019, you can no longer create spending limits, but you can change or remove existing spending limits.

https://cloud.google.com/appengine/pricing#spending_limit

You can create budgets, which will alert you when reaching the budget. But it won't stop the usage when hitting the budget.

https://cloud.google.com/billing/docs/how-to/budgets#add-new-budget

Solution 3

The screenshot here seems to show a Spending Limit setting for Firebase projects: Firebase: Budget and Daily Spending Limit

That settings page is located here (the Spending Limit setting apparently only shows up once you set up billing for the project): https://console.cloud.google.com/appengine/settings

It's disabled in the poster's case, but I think that's only because he connected it up to a "NodeJS App Engine app", which isn't the case for many Firebase developers.

I haven't tried it yet myself, but will do so once I start a paid plan.

EDIT: Yep, the setting shows up once you switch to a paid plan. (in my case, Blaze) I don't have enough traffic yet to confirm that it works as expected, but if I find later that it doesn't, I'll give an update here.

Solution 4

"This example shows you how to cap costs and stops usage for a project by disabling Cloud Billing. This will cause all Google Cloud services to terminate non-free tier services for the project."

Google Cloud Source

Share:
18,910

Related videos on Youtube

Franco Muñiz
Author by

Franco Muñiz

Hey there, I'm Franco and I'm 19 years old. Currently studying Computer Science. I've got experience with JavaScript, Python, React, React Native, MongoDB, Node, Express, AWS and some other technologies.

Updated on July 19, 2022

Comments

  • Franco Muñiz
    Franco Muñiz almost 2 years

    I'm currently working in a social network app and I need to do a search feature. Firestore does not support these kind of queries, so I need to use an external service like Algolia.

    The problem is that the free plan does not support connecting to external websites/APIs other than Google's own ones, so I can't connect to Algolia to get my search system working.

    I have read multiple stories about devs paying high bills because of loops or errors in their code, and as the Blaze plan is a pay-to-go plan, they get charged what they used. If a loop generated 10TB of files they will get charged for that.

    I also know that Blaze plan's features are free as long as each of them (individually) stay below the limits of the free Spark plan.

    So as my question says, is there a way to set limits? For example, I would like to tell Firebase to limit my cloud functions invocations to 100k per month. That way it would be free and I would never be able to get over 100k as it's limited, which means I'll never get billed for that.

    Take into account that the only thing I need right now from a paid plan is the connection to external networks. I don't need anything else as we're just starting and the app is not in production, so there's no need for huge limits.

    • Doug Stevenson
      Doug Stevenson almost 6 years
      I will say that for something like mirroring content to Algolia, it's very difficult to write an accidental loop. Accidental loops can only happen when you have a trigger that does something to trigger itself (such as database trigger that writes back to the database), without detecting an appropriate exit condition and terminating early. If all you want to do is copy data outside of your database, and you never want to write back into your database, your chances of writing a loop are 0.
    • Franco Muñiz
      Franco Muñiz almost 6 years
      I totally agree with you in this case. But we will use many Firestore tools, not only external connections. We are already constantly using functions, database, storage, and we're soon going to expand them and use them even more. This is where I'm afraid an accidental loop could happen, especially given the fact that it's our first time with Firebase and a huge scale back-end development. If we have a loop right now, we'll be limited by the free plan and we won't get a bill. But if it happens with the Blaze plan, it'll be pretty annoying even if we can manage to "cancel" it.
    • Doug Stevenson
      Doug Stevenson almost 6 years
      You might be helped by having a staging area where you can test your code for bugs like this, before you deploy to production, where it will truly be costly.
    • Doug Stevenson
      Doug Stevenson almost 6 years
      In any event, all Firebase projects are also Google Cloud projects, so whatever Google Cloud provides is what you have access to. Which is not much, according to the duplicate.
    • Franco Muñiz
      Franco Muñiz almost 6 years
      I'm not sure I understood the "staging area" concept. I need to use Firebase to test my project. Everything is connected as it's a social network. I have users and all their data in Firestore Database, their images/videos in Storage, of course I use Auth, then I use Functions, and now I want a paid plan to remove the network limitation which will be linked to the other tools. How can I have a staging area without a Blaze plan but with the possibility to use the "outside networking" feature? Not sure if that's possible..
    • Doug Stevenson
      Doug Stevenson almost 6 years
      Create a separate project with enough data to simulate how a real product would work. Deploy your code there first. Test it exhaustively. Monitor closely for loops and errors. If there is a problem, shut down your code. After all your tests pass, publish your code to production. You can probably even do this for free given the perpetual free tier for projects on the Blaze plan.
    • Franco Muñiz
      Franco Muñiz almost 6 years
      Ahh, got it now. The free tier from Blaze plan will come in handy too. Thanks for the idea! Will start applying it soon.
    • Doug Stevenson
      Doug Stevenson almost 6 years
      What's not obvious is that the limits of the free tier are always free for projects on Blaze. You won't be billed on Blaze until you exceed any monthly limits from Spark.
    • Amit Klein
      Amit Klein almost 4 years
      @DougStevenson Do you know why google disabled "spending limits"?
    • Doug Stevenson
      Doug Stevenson almost 4 years
      @AmitKlein That's a question to direct to Google. You can try contacting Firebase support.
    • Martin Cremer
      Martin Cremer about 3 years
      the free plan doesn't provide cloud functions at all. I hope i won't owe google billions some day.
  • MadMac
    MadMac about 5 years
    I could set it to $0 but not sure if it is working as I have not used the account enough to go above the free limits.
  • MadMac
    MadMac over 4 years
    The spending limit has been taken away. Important: Cloud Firestore no longer supports new App Engine spending limits. After December 12, 2019, you cannot apply new App Engine spending limits. Spending limits set before December 12 still apply.
  • Sébastien
    Sébastien about 4 years
    Unbelievable. The feature that protected Firestore customers from bankruptcy (by human error or DDOS attack) was already there. But Google removed it!
  • Daniyel.Me
    Daniyel.Me almost 4 years
    @Sébastien can you please provide a source on them having and removing it?
  • Sébastien
    Sébastien almost 4 years
    @Daniyel.Me the source is in the answer above. It used to be possible to set "hard" spending limits. This is all I would have needed, but it's gone 😡
  • Bob
    Bob over 3 years
    It seems the billing alerts and with this the capping can be delayed by some days! See at your link: "There is a delay of up to a few days between incurring costs and receiving budget notifications. Due to usage latency from the time that a resource is used to the time that the activity is billed, you might incur additional costs for usage that hasn't arrived at the time that all services are stopped. Following the steps in this capping example is not a guarantee that you will not spend more than your budget."
  • zacoder
    zacoder over 2 years
    They are making it complicated to disable-stop-limit the usage from exceeding. It is not what I expect from google.