Cloud Firestore Read Operation 10 Times Higher in Billing - firebase

One of my App uses Firebase Firestore and has almost never exceed the daily free quota of 50k read operations. However last month I was charged for a few millions Firestore read operations.
Wanting to find out what was the problem, I checked my console (Usage and Billing) and confirmed that my everyday usage was under the 50k daily free quota during the whole billed month. Then I checked my usage today, in Firebase Console (Usage and Billing) it showed I have 45k read operations, but in my Google Cloud Platform (Quota), it showed 0.45m read operations, which was 10 times higher.
Anyone faced this problem before? What could've gone wrong?
Thank you in advanced.

I had the same problem (it was also 10 times the amount!), and I am pretty sure for me it must be because reads to do backups are not counted on the firebase usage page, but are billed. For a large database backups can be quite a problem.
It turns out there is a message here:
https://firebase.google.com/docs/firestore/manage-data/export-import?authuser=1
It says:
"Caution: Exporting data from Cloud Firestore will incur one read operation per document exported. However, these reads will not appear in the usage section of the console. Make sure you understand this before setting up recurring exports to avoid an unexpected bill."
Hope this saves someone a bit of time!

Related

Hows does firebase firestore read counted?

Please someone help me to know how does the firebase firestore read counted.
I noticed that whenever i view my data in firebase console that too taken as in "read" so my doubt is whether i would be charged when my client view the fetched data in the app too! initially i thought that
i would be charged only for the "read" done by the user in my app. I know that 1 document is equal to one read, but i never knew that read is also counted when we actually see the data in the firebase console.
so please help me to know the right way to use it, this is creating a headache for me. and thanks in advance
You're charged for reads in the console too. Generally, this number is low during the development phase and should easily be covered by the free trial.
If your documents are excessive, you may prefer building a separate admin dashboard for him/her. Using
If you are charged heavily just for opening the firestore console, you may consider creating a blank collection with the name a - so that whenever you load firestore console, only documents in the a collection are loaded.
One Firestore document read is counted (and charged if you have reached the free quota limit of 50K/day for reads) in both cases: the document is read from the Firebase Console or the document is read from your app.
help me to know the right way to use it
There is no real "right way". You are charged one document read each time you read a Firestore doc (whatever is the way of reading it) and you have reached the free quota limit (i.e. 50K/day for reads)
You will find more details in the dedicated Firestore doc.

Firebase Blaze plan and Cloud Functions

Unfortunately Firebase's Flame plan disappeared and I now have to deal with Blaze plan, which I'm not fan of because of it's "unlimited" budget (but my wallet isn't). Yesterday I was coding and by mistake made a loop that called 3 Cloud Functions, I spotted the loop fast enough to stop the carnage.
In only 15 seconds of execution, I've been able to trigger more than 10K requests, and without errors, that a pretty good performance of Firebase, but it's scary as well! How can I cap this to throttle requests coming from users? I'm pretty confident in my code, but as we all know if someone gets my Firebase config file, I'm done.
I'm a solo developer and it's my first app done on my spare time, I don't want to to become a mess because of triggering reads / writes / Cloud Functions. No one is perfect, everyone makes mistakes, maybe I didn't spot a small bug in my code that'll reveal it's true potential only once in production. I'm not asking Firebase to handle my mistakes, but I'd like to be able to stop the CF and Firebase if I want to.
My only desire is to sleep confident, I don't want to wake up one morning with a 10.000$ bill. I've read that's it's possible to totally disable billing account on a project with CloudFunctions, but what will happen to my Firebase Storage bucket for example (for the storage superior to the Spark plan)? And it doesn't seem easy to do.
Firebase is a great product and I love how easy / fun it is to use, but now that budget locked plans as Flame are gone I feel really trapped now that my application is almost ready to go into production, and I don't think I'm the only one out there.
Ah you've stumbled onto the 'rate-limiting' conundrum. Not to worry, I've spent many nights worrying about this myself.
In order to get a bit more control over your application, you're going to have to link your project to google cloud platform. Then navigate to IAM & Admin>Quotas (once you've selected your firebase project).
Now you might be overwhelmed initially, and confused as to why there are so many Cloud functions API limiters. These quotas should allow you to rate limit your cloud functions API (similar to what twitter does) in a number of ways, including but not limited to:
Read Requests per day
Read requests per 100 seconds
Function invocations per 100 seconds
Function invocations per day
etc
The API that will be listed are the ones you've enabled, so you can set limits for cloud storage as well.
By default, the max number of invocations per second is set to the maximum of 5000 invocations per day on the spark plan. but according to the docs, the absolute maximum is 100,000,000/100 seconds!
Also worth having a look at is the pricing docs, which have a nice example of a typical monthly use case for a successful app. To grossly oversimplify, a single invocation costs $0.0000004, hence 10,000,000 invocations will cost you a whopping $3.20. However don't let that very low cost fool you, if you write some terrible code and it has exponential complexity (like reading every document in a firestore collection every invocation), you could get slapped with an exponential cost. So make sure you set those quotas :)
Remember, server admin is as much a part of the application as the code itself. If your app goes to production, be prepared to spend some time each day going through the Google cloud dashboard and checking limits, analyzing trends, etc. This way you can kind of step up the amount of invocations you can allow per day and sleep well knowing that if you shoot yourself in the foot, you won't bleed too much.
Best of luck with it
Despicable B.

Firebase Realtime Database detailed usage

Where can I get Firebase Realtime Database detailed usage i.e. I want to get details about where data is being used? My database size is about 700kb and 10GB downloaded in 2 days, I am unable to figure it out, how did this happen. Currently, the usage tab just showing me the basic usage by day. Can I get more detailed usage information?
See the Firebase documentation on monitoring usage, which lists two main options:
The Usage in the Firebase console, which you already found.
StackDriver monitoring, which will you give you more granular usage data.
If neither of these allow you to determine where the usage is coming from, you have a few more options/things to consider:
Keep in mind that traffic for showing the database in the Firebase console is also charged. Especially early on in development this can be a major portion of the usage, as you won't have many users yet.
You can use the database profiler, which logs all the activity in your database over a given period of time.

How fast can i reach 1GB in firebase realtime database

I am using firebase database and my question is, for example how fast can I reach 1GB if i have 100 users each storing worth 10 document pages of microsoft word full of text everyday, for one month?
Word documents would be stored in Firebase Storage, not the realtime database. Realistically, the only way you will be billed anything for using the Firebase platform is if your app gets a significant of usage. I suspect that 99% of firebase apps do not generate any billing whatsoever. ...that's just a hunch.
If you do run into billing issues, that will/would be a good thing.
Although this question is too broad since it lacks various variables like the number of users, size of the files and how this data is presented in the app I will try to give my $0.02 on this in a very generic way which can also be interpreted as how not to end up with a huge bill while using firebase,
Even though Firebase provides a sufficient space to test out the app in production there is a lot of ways in which things can go bad real quick like,
1) since firebase automatically handles the sync this additional read/write call comes out of your quota apart from the call you trigger check-out how one app developers found this out the hard way
2) if you have bad DB schema/design that you have not addressed, then you end up making multiple calls to the server to fetch the data which again bloats up the number of calls you make read about this here
3) Not setting spending limits and alerts, this should be a mandatory step to avoid a lot of the above problems even though the docs clearly gives an indication on how to set this up
These are some of the cases that I have come across I hope this serves as a guideline to set up your app

Firebase storage states full after deleting all files

Like many other people out there, I am using Firebase for my project. In the past few days I have used Firebase quite a lot for sending media files between users. Now, I am also on the free plan, as I am still testing Firebase.
All of a sudden, Firebase has stopped responding, mentioning that
"You have exceeded your quota for this project. Please upgrade your plan.
LEARN MORE"
I know that Firebase has a limit on the amount of data I can transfer per day and store, that's no problem. My problem is that even after a full day, and having everything in storage deleted, I still get the same error.
Truth is, this error only shows up for the storage section. But, as you can see in the picture, my storage is now empty. Therefore my question is how can I reset firebase, or there's no other way around other than paying?
Since I am not able to see any files, I am also suspecting that I have not deleted them all, or them correctly? Could this be what's going on?
The more interesting part is the when clicking on "LEARN MORE", I am prompted to the following page, which is even more misleading.
Update: After looking at my quota details I found out that my Cloud Storage Network is full:
Looking at the Pricing for Storage on the Spark Plan it says that you can store up to 5Gb of data. Now this plan is based on Cloud Platform's Always Free and their documentation says "5Gb-months". I'm not sure of what that means, but I'm assuming that you have already exceeded your 5Gb for this month (even though you deleted the files afterwards). Maybe your quota will actually have some kind of "refresh" next month so you'll probably only be able to use Firebase storage again by that time.

Resources