Whether you're just starting out developing your app or you have a full-blown
production app, you want to make sure you understand your costs and how to avoid
surprise bills.
If you haven't already, check out the
Firebase pricing
plans
to understand how billing
for works for Firebase.
This page guides you through important aspects of understanding and monitoring
your usage and spend levels, including:
Test your code
Testing your code before deploying to production is a great idea for many
reasons, like catching errors that might cost you significant amounts of money.
As you're building the infrastructure for your app,
we highly recommend first
testing locally using the
Firebase Local Emulator Suite
.
The Local Emulator Suite allows you to run instances of Cloud Functions,
Cloud Firestore, the Realtime Database and more all locally on your desktop machine.
This not only makes it easier for you to quickly iterate on new functionality ?
particularly Cloud Functions ? but it also ensures that you don't incur any
Firebase costs that might result from testing against services in production.
As you're testing, check for these common causes of exceeding expected usage and
spend:
View your usage and spending levels
You need to know what normal usage patterns look like for your app and make sure
you're staying within thresholds important to you.
View individual product usage
You can view individual product usage in the "Usage" tab for many products in
the Firebase console.
View overall project usage
You can view your project's overall usage in the
Usage and billing
dashboard
in the Firebase console (go to
Project Settings
>
Usage and billing
).
You can view your monthly usage and how your usage levels are
measuring up to the allocated no-cost usage quota.
Click into any product to review a daily summary of usage and how it
measures up to the allocated no-cost usage quota.
Remember that each product has different usage quotas and thus different
timelines, for example:
Set up budget alert emails
Avoid surprises on your bill by creating budgets in
Google Cloud Billing and setting up budget alerts. This section
describes how to do both of these for your Firebase project.
You can set up simple budget alerts that send you and your teammates email
notifications when your project exceeds a set spend threshold.
You might already have a budget alert if you upgraded to a Blaze pricing plan
recently. But if you want to learn more about budget alerts, set up a new alert,
or modify an existing alert, this section is for you!
Overview of budgets and budget alerts
Budgets are general dollar amounts that you plan on spending each month.
A budget alert sends an email whenever your project's spending level hits a
threshold that you've set. Budget alerts do NOT turn off services or usage for
your app.
We don't turn off services and usage because although you
might
have a bug in
your app causing an increase in spend, you might just be experiencing unexpected
positive growth of your app. You don't want your app to shut down unexpectedly
when you need it to work the most.
Set up a budget and a simple budget alert
To set up a budget or a budget alert, you need to be an Owner of the associated
Cloud Billing account.
Go to the
Google Cloud console
,
access your project, then select
Billing
.
Go to the
Budgets & alerts
panel, then complete the following steps to
set up a budget and an emailed budget alert:
Select an existing budget or create a new one.
Give your budget a descriptive name.
Set the scope for the budget alert, including the project(s) and
service(s) that you want the budget alert to apply to. You probably want
to select
All services
when getting started with budget alerts.
Set the
Amount
>
Budget type
using one of these options:
A set amount of money
? use this type when you're first starting
out or testing your app
An amount equal to what your project spent last month
?
use this type when your app is growing steadily and you don't want
to keep updating the budget amount every month
Set up
Percent of budget
alerts.
For initial testing, try out several percentages, like 1%, 2%, 5%,
and 50% of
Actual
.
For production apps, try out pivotal percentages, like
50% and 100% of
Actual
as well as 150% of
Forecasted
.
Set up who should get emails.
By default, anyone with the appropriate billing permissions gets the
notification email (by default, Billing Account Administrators and
Billing Account Users on the associated Cloud Billing account).
You can also send emails to other people on your team. This requires
creating a Cloud Monitoring Workspace and then adding an
email-based notification channel to the
Alerting
section of the
workspace. For more information about this setup, visit
Set up advanced billing alerts
and logic
.
If you set up a notification for a low
Percent of budget
(like 1%),
you should get an email within a couple hours or a couple of days telling
you that your project has hit that threshold.
Next steps
Visit
Set up advanced
billing alerts and logic
to learn how to do the following:
Use Cloud Monitoring to create more sophisticated alerts for billing and
usage, including custom alerts that send notifications to other mediums,
like Slack.
Create additional billing logic based on Google Cloud Pub/Sub.