# Firebase & GCP: Billing & Pricing limits
## In a nutshell
* b.vaneeckhout@medc2.com and g.gustin@medc2.com are both administrators of GCP and Firebase interface and have now access to everything related to the MedC2 Google-based projects (resources, configuration, users permissions, billing etc.)
* The GCP console for ImmunoSabr (the only "Blaze" paid plan we subscribed so far) can be found [here](https://console.cloud.google.com/home/dashboard?project=immunosabr).
* EDIT: actually for unknown reasons, only vaneeckhoutbrice@gmail.com has the ability to see all the billing details and modify limits. To be investigated ;-)
* The Google Cloud Free Tier has two parts:
* **A 12-month free trial with $300 credit** to use with any Google Cloud services.
* **Always Free**, which provides limited access to many common Google Cloud resources, free of charge.
* Most of services we use lie in the **Always Free** limited range. To have clear overview on the Firebase resources/usage, [check this link](https://console.firebase.google.com/project/immunosabr/usage).



* The main metrics we should take care in the future, in order to stay under the free tier if we scale to a larger number of participants, is related to Firestore reads due to Scheduler and push notifications. However, reducing the scheduler to 1/24h in `index.js` (Cloud functions) should be sufficient.

* The only Google Service we use that is not part of the **Always Free** plan, is the *Google Scheduler*, but even for that feature we still currently benefit of it for free.
* More specifically, we use it in the ImmunoSabr project inside Cloud functions, to check on a daily basis (every 3 hours) if we have to send push notifications to the participants, depending on ePRO questionnaires they have to fill in.
* However, it will still remain free for us because:
> - Cloud Scheduler pricing is based exclusively on the job. A Cloud Scheduler job defines a single activity scheduled to run at a frequency provided in the definition.
> - Each Google billing account gets 3 jobs per month free. Note that the free tier is measured at the account level not the project level.
## Limits and notifications
* To make sure we never exceed the **Free Plan**, I added budget tresholds (10eur) with vaneeckhoutbrice@gmail.com account, we will both receive notifications by mail if we exceed this limit.

- To check the budget treshold configuration for ImmunoSabr, [visit this url](https://console.cloud.google.com/billing/012F6E-6D934A-154E8C?project=immunosabr) :-)
* NB. Idk why, the permissions should have been given to my account as well as suggested by: 
* ... but it is not the case.Only vaneeckhoutbrice@gmail.com can modify billing alerts for now.

* even when modifying IAM permissions to this:
 ...
## Interesting resources
* [Overview Firebase usage/resources](https://console.firebase.google.com/project/immunosabr/usage)
* [Firebase pricing calculator (Blaze)](https://firebase.google.com/pricing#blaze-calculator)
* [Article, "How to manage Firebase costs"](https://www.ericdecanini.com/2019/03/04/managing-firebase-costs/)
* [Firestore: How to stay within the limits of Firebase's new database free tier](
https://www.freecodecamp.org/news/firestoreliving/)
* [Google Cloud Free Tier info](https://cloud.google.com/free/docs/gcp-free-tier)
* [Firebase Pricing](https://firebase.google.com/pricing)
* [Google Scheduler pricing](https://cloud.google.com/scheduler/pricing)