Firebase deployment and small-scale charges

If you are using Firebase and you have upgraded to a Blaze account, perhaps have you noticed that during the last months, you've been charged—a few pennies—to use the Google Cloud Infrastructure.

Here is a screenshot of what I mean:

Firebase charging a few cents

The thing is that if you take a look at Usage and Billing, you'll see that you may not surpassing the free tier limits:

Firebase free tier

The problem

A few cents are not the problem, the problem is that it's difficult to understand what Google is charging for and how they calculate the previous parameters.

I contacted the Google team a few days ago to clarify things, and they told me the following:

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. See Firebase Pricing plans and the Cloud Functions Pricing example scenarios.

So, they are charging money for the storage used via Container Registry.

Where is this Container Registry and how can you take control of it?

Well, let's see:

  1. Go to Google Cloud Console.
  2. Select your Firebase project on the top navigation bar.
  3. Resources > Storage
  4. Select the bucket starting with us.artifacts

This is the folder they are charging you for.

The solution

Per the documentation:

Each time you deploy a new version, a container image is created using the Cloud Build service. That container image then runs in the App Engine standard environment. Built container images are stored in the app-engine folder in Container Registry. You can download these images to keep or run elsewhere. Once deployment is complete, App Engine no longer needs the container images. Note that they are not automatically deleted, so to avoid reaching your storage quota, you can safely delete any images you don't need. For more information about managing images in Container Registry, see the Container Registry documentation.

Once a deployment is completed, App Engine no longer needs the container images. So you can delete all the images of the folder manually.

After deleting the files, instead of doing the process always manually, you can configure it to auto following these steps:

  1. Go to Google Cloud Console.
  2. Select your Firebase project on the top navigation bar.
  3. Resources > Storage
  4. Select the bucket starting with us.artifacts
  5. Lifecycle > Add rule
  6. Select an action: Delete object
  7. Select object conditions: Age
  8. Write the number of days, e.g. 1 day

The container images will be deleted every day and you won't be filling your bucket.

Hi, I'm Erik, an engineer from Barcelona. If you like the post or have any comments, say hi.