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

5

59

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.

Departmentalize answered 14/9, 2018 at 2:43 Comment(11)
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.Variate
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.Dufrene
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.Variate
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.Variate
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..Dufrene
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.Variate
Ahh, got it now. The free tier from Blaze plan will come in handy too. Thanks for the idea! Will start applying it soon.Dufrene
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.Variate
@DougStevenson Do you know why google disabled "spending limits"?Guthrun
@AmitKlein That's a question to direct to Google. You can try contacting Firebase support.Variate
the free plan doesn't provide cloud functions at all. I hope i won't owe google billions some day.Chaunceychaunt
T
29

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.

Terrijo answered 14/9, 2018 at 4:32 Comment(1)
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."Speckle
W
14

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

Wickman answered 22/5, 2020 at 1:9 Comment(3)
Unbelievable. The feature that protected Firestore customers from bankruptcy (by human error or DDOS attack) was already there. But Google removed it!Charley
@Sébastien can you please provide a source on them having and removing it?Flemming
@Flemming 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 😡Charley
M
5

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.

Misesteem answered 11/11, 2018 at 18:2 Comment(2)
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.Shackleford
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.Shackleford
L
2

"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

Lentigo answered 17/1, 2021 at 16:0 Comment(1)
They are making it complicated to disable-stop-limit the usage from exceeding. It is not what I expect from google.Dislocate
D
0

I created a prepaid credit card and put $20 in it. I used Revolut, but there's a bunch of them you can use.

Link that card to your Google billing payment and you're set. Just remember to top it up when it's low on funds. Most prepaid cards allow for auto-top-up from your personal credit card, but that would defeat the purpose.

Dorelle answered 11/12, 2023 at 23:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.