23

I am trying to figure out why firebase storage usage is far above my expectation enter image description here

I only have few photo files in my Firebase storage, just around 75 photos, 100kb for each photo. but my bytes stored and object counts is way above my expectation as you can see in the image above. in this case, maybe I find the answer from the documentation in here

When you deploy your function's source code to Cloud Functions, that source is stored in a Cloud Storage bucket. Cloud Build then automatically builds your code into a container image and pushes that image to Container Registry. Cloud Functions accesses this image when it needs to run the container to execute your function.

The process of building the image is entirely automatic and requires no direct input from you

it is probably because I create a lot of cloud function. thats why the bytes stored and object count in my Firebase Storage is big

now I need to know why storage bandwidth is up to 20.2 GB in a month. I am still developing my app, the user is just me. I don't think I will hit 20.2 GB in a month, because in my Android app, I use cache when showing the image.

I am suspicious, the reason why my storage bandwidth usage is too high is because of cloud function. in August, I perform a lot of firebase deploy to my cloud function. will Cloud Function affect Firebase Storage bandwidth usage ?

I am in Indonesia, my Firebase Storage and Firestore are located in asia-southeast2, but my Cloud Function is located in asia-east2. my cloud function perform some operation to my firestore and images in storage. but still I don't think it will hit 20.2 GB per month

as you can see from the image above, the bandwidth usage is separated into 3 different parts

  1. asia.artifacts.projectID.appspot.com
  2. gcf-sources-5900904-asia-east2
  3. projectID.appspot.com

the asia.artifacts.projectID.appspot.com seems way above the other, it is up to 4.3 GB

thats some information of my problem. so I need to know, will cloud function deployment/operation affect my Firebase Storage Bandwidth usage ?

I need to understand why this is happened, because I am worried that I will have unexpected cost if a lot of users use my app.

Alexa289
  • 8,089
  • 10
  • 74
  • 178
  • Did you solve this problem? I've deployed 12 different Cloud functions recently, now Bandwidth reached to 15 GB daily. Daily users were just 2. :(( – zemunkh Nov 22 '21 at 15:07

2 Answers2

8

I was surprised by the bandwidth usage too.

First, Firebase Changed some policy

After August 17, 2020, each deployment operation will incur small-scale charges for the >storage space used for the function's container. For example, if your functions consume ?>1GB of storage via Container Registry, you'll be billed $0.026 per month. If your >development process depends on deploying functions for testing, you can further minimize >costs by using the Firebase Local Emulator Suite during development.

So the most reasonable explanation is cloud function build during npm install generates bandwidth usage of downloading node_modules and also takes up storage.

I would suggest use local emulator during development as much as possible, but many cases production test is inevitable, so sad.

詹易衡
  • 96
  • 1
  • 1
2

The part of the documentation you quoted that's relevant here is:

Cloud Functions accesses this image when it needs to run the container to execute your function.

The built images are being accessed by Cloud Functions in order to run your code that's built into the image. Although the documentation doesn't specify, I would guess that every cold start of a function requires a download of the image from the artifacts bucket. This would explain the usage on that bucket.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
  • one more question Sir, little bit out off topic. I just realised that Cloud Function is now available in asia-southeast2, Indonesia. (currently my cloud function is in asia-east2, Hongkong). so, if my Firebase Storage and Cloud Function both are in the same region (asia-southeast2), it will be considered as Network egress within Google Cloud, and it will be free becase the data moves from the same location. am I right ? I see from here https://cloud.google.com/storage/pricing – Alexa289 Sep 02 '20 at 01:54
  • If you have very detailed questions about billing, I strongly suggest contacting Firebase support directly, as they will be able to tell you for sure about your specific situation. The documentation just does not address Cloud Functions specifically. https://support.google.com/firebase/contact/support – Doug Stevenson Sep 02 '20 at 02:06
  • 1
    I have tried to contact the support and ask different question. there is a change since August 17 2020, Cloud Functions for Firebase will rely on some additional paid Google services: Cloud Build, Container Registry, and Cloud Storage. https://firebase.google.com/support/faq#functions-pricing . maybe thats why the bandwidth in artifact increase and I also get charged for Cloud Build :( .and it seems to me that bandwidth will increase whenever I deploy a function (`firebase deploy`). I don't really understand about this – Alexa289 Sep 03 '20 at 00:40
  • 2
    i have the same situation here. 5 basic cloud functions used 800 mb cloud storage and i have to pay for some reason. do we have relay meaningful explanation for this? – mtalha Sep 07 '20 at 18:56
  • 5
    I noticed the very same thing today for the first time. When I deployed a single function as my first Firebase Function for a new project it ate up about 400MB of bandwidth. However, each subsequent deploy of slight modifications fo the same function ate up on average only about 20MB extra bandwidth. Stoke is low on this new billing update :( – mpc75 Sep 10 '20 at 18:27
  • 2
    I am already getting billed, while I am in process of development. I don't understand what they are up to. 99 % of the storage is consumed by the cloud functions. I wonder what will happen After I publish the App. – Ashir Mehmood Sep 18 '20 at 19:17
  • For everyone worried about getting billed, I suggest using the [emulator](https://firebase.google.com/docs/emulator-suite/install_and_configure). I know it won't satisfy every use case, but at least tinkering around with functions while using the emulator won't eat your wallet. – Mark-4421 Sep 26 '20 at 21:33