Understanding Firebase Costs

A Firebase guide to understanding pricing, managing costs, and tracking usage.

Introduction

Firebase is a mobile and web app development platform that helps you build quickly and handles a lot of fundamental infrastructure tasks such as database management, hosting, serverless functions, messaging, and monitoring.

An ongoing concern for Firebase users is cost since Firebase's pricing model is confusing and difficult to track accurately. If you search Google for "Firebase costs" you'll see a lot of horror stories about large unexpected bills. However, with a little knowledge and fireRun.io, you can monitor and manage your Firebase costs so you don't get into trouble.

The Spark Plan (free)

Firebase offers two plans: Spark and Blaze.

The Spark Plan is Firebase's free tier with a very generous allocation offering. The plan is fantastic for startups or those looking to do MVPs. You can set up an entire website or mobile app with a database, messaging, cloud functions, authentication, and a custom domains with SSL for free and have a significant number of users (depending on your app requirements).

No credit card is required to sign up and you will never incur a bill. While that sounds great, it is also part of the danger of being on the Spark Plan.

When your Spark plan's free daily or monthly usage runs out, the Firebase APIs will start refusing requests. Without warning your app can shutdown.

If you have a mission critical app or don't want your app to suddenly shut down, consider upgrading to the Blaze plan.

There are also some restrictions on the Spark plan; for example Cloud Functions can only make API calls to Google APIs. So if you need to fetch from a non-Google service, you'll need to upgrade to the Blaze plan.

The Blaze Plan (pay-as-you-go)

The Blaze plan is pay-as-you-go and requires you to set up billing with a credit card. It is made for larger scale apps or when you can't afford to exceed your free quota and have your app shut down.

You are charged based on your storage and usage of Firebase, so you only pay for what you consume. You still get your free allocation and will only be charged once you go over your quota. Some charges occur daily, such as Firestore reads, or monthly, such as Cloud Function invocations.

However, with your Blaze plan, you can set setup limits and budget alerts, which we'll discuss below.

The Firebase Console

In the Firebase console you can see a lot of details about your current month usage and spend.

Accessing Usage and Billing

In your Firebase console, click on the gear icon in the upper left corner and select "Usage and billing".

Reviewing Your Usage and Spend

Project Costs

You will see your estimate project costs for the current month broken down into Cloud Firestore, Functions, and non-Firebase services.

Previous month usage details are not available in the Firebase console. You need to go to the Google console to see historical data.

Also, the free tier section is missing several usage metrics that you are charged for such as Firebase storage, Cloud Function invocations, and network egress.

Fire Tier Quota

Below the Project costs graph is a section called "Free Tier" of your usage per features (e.g. Firestore) and the percentage of you're free tier used so far.

As noted above, if you're on the Spark plan, you need to carefully track how much of your free quota has been used. If you hit the limit, Firebase will stop accepting API requests. In the example above, once the 1 GB Hosting storage limit has been hit, you will no longer be able to release new code without deleting old ones or moving to the Blaze plan.

To automatically managing Hosting storage, keep only a limited number of previous releases (for redeployment purposes). Under Hosting -> Release History, click the three vertical dots to set the number of backup copies kept.

Individual Quotas

Finally each section under "Develop" on the left side-panel has a "Usage" tab that show the top metrics for the given functionality. Below is an example of the Database (Realtime DB) usage.

Setting a Budget

Setting a budget is a smart move if you're on the Blaze plan. Setting a budget requires that you have billing setup up in the Google Cloud Console (i.e. you're on the Blaze pay-as-you-go plan).

Under "Usage and billing" click the "Details and Setting" tab. There you will see a card with a link to Google's console's budgeting too. Click the link and you'll be brought in to the Google Console budgeting wizard.

You can also set a Firebase budget in fireRun.io that is a one set process.

pageFirebase Budget Alerts

The Google Cloud Console

Behind the scenes, Firebase runs on top of Google Cloud. The Google Cloud Console (GCC) is the means by which you access and manage the cloud functionality. Here you can dive into the gory details of usage and billing by taking a look at the man behind the curtain (Google Cloud).

Accessing GCC

As before, go to "Usage and Billing" by clicking the gear icon in the left side-panel.

Hover or click the "Beta" tag and then click the "Google Cloud Console" link.

Reports in GCC

The Google Cloud Console is a large app with a lot of functionality. We will not cover all the capabilities here, except for one: Reports. Report are useful to see where your cost are for a give function.

Open the console Navigation menu (menu), and then select Billing and then Reports

In Report, you can select the time period and "Products", such as Firestore, you want to filter on. You will be able to view the break down of cost over the course of the month. Unlike in the Firebase console, here you can view your historical data.

Quick Tips

A few tips on how to approach Firebase costs and usage.

General Plans and Billing

Biggest Costs: Your Read, Writes, and Delete will probably be your biggest cost. And never store images in the database. Store in Cloud Storage.

Set a Budget: A good idea to set a budget close to what you think you'll be spending. See link.

pageFirebase Budget Alerts

Billing Questions: You can reach out to the Firebase Billing Team directly.

Cost calculator on Pricing Page: The calculator at the bottom of the Firebase Pricing page is inaccurate. For example, it indicates that 600,000 monthly Firestore writes are free. In fact you only get 20,000 free writes a day (and $0.18/100K after). If you write 120,000 in a day you will be charged $0.18 even if your monthly is below 600,000.

The Flame Plan: The plan ($25/mo) was removed by Firebase as an option. In practice, anyone who was on Flame was also very likely to be paying too much for their actual usage, which would cost less if they were on Blaze.

Hosting

Use Caching: Firestore allows you to use offline caching. Request go to your local cache instead of the server, thus reducing the number of billable reads.

let snapshot = await documentRef.get({ source: ‘cache’ }); if (!snapshot.exists) { snapshot = await documentRef.get({ source: ‘server’ }) }

However, if your data is not immutable, you might need to manually manage the lifecycle of the data since this technique will never get refreshed data from the server.

Caching is only available for iOS, Android, or Web - not in Cloud Functions.

Firestore and Real-time Database

Firebase Database Costs: Realtime DB biggest costs are the amount of data transferred and stored. Firestore biggest costs are the number of read, write, and delete operations.

Set Firestore Spending Limit: Google stopped offering Firestore Spending Limits back in 2019. If you're on the free Spark plan and you hit your daily Firestore read limit, you will be blocked from additional reads until the following month or you upgrade to Blaze.

On the Blaze plan prevent overspending by tracking your daily and weekly Firebase usage and setting up a Firebase budget. See links below on how to set these up.

Am I Charged for Writes When the Data Doesn’t Change? Yes, you will be charged for writes to Firestore (Realtime DB doesn't charge for writes) regardless if the data is different. Firestore doesn't do compares on your behalf.

With the different functions you'll be charge for every document write:

  • set/add: create a new object or overwrite the existing one if the same id.

  • set with merge: overwrite the fields that you pass to set. All others fields will remain the same. If the document doesn't exist, it will be created.

  • update: update some fields of a document without overwriting the entire document. Like set with merge, but will error if the document doesn't exist.

pageSet Up Your First ReportpageFirebase Budget Alerts

Cloud Firestore Charges For:

  • The number of reads, writes, and deletes that you perform.

  • The amount of storage that your database uses, including overhead for metadata and indexes.

  • The amount of network bandwidth that you use.

Important to note that a Firestore query isn't one read. If you ask for all the French restaurants in your area and 10 documents are returned, that is 10 reads. You can use pagination to limit results.

Furthermore, the document reads and not the fields within the document are what count. So if the 10 documents have 5 fields each, only 10 reads are counted.

Firestore Security Rules: Believe it or not, but certain Firestore security rules count as reads. f you use exists(), get(), or getAfter(), you are charged for additional reads for the query running, docs return for the evaluation, or updating the rule. See the complete list.

Firestore Minimum Charge: There is a minimum charge of one document read for each query that you perform, even if the query returns no results.

Firestore Pricing Depends on Location: Where your server runs changes your quota limit and pricing. Use this chart to see for your location.

Cloud Functions

Cloud Functions: On the Spark plan, outbound networking calls are only allowed to Google services. If you want to make calls outside of Google you need to be on the Blaze plan.

Optimize for Cost: Probably is not wise to over optimize for pricing. Just be sure not to do any dumb moves (like an infinite loop in your code). Saving developer time for $0.20 a day probably isn't worth it.

Additional Resources

External Firebase Resources

  • A great video from Firebase that reviews not only Firestore pricing, but overall Firebase pricing.

  • An in-depth discussion on how Firebase relates to Google Cloud.

fireRun.io Dashboard

Head back to your 🔥fireRun.io Dashboard 🔥to see you usage and spend.

Questions or Help

Please email or chat with us for any questions or comments

Last updated