Auto Stop Services
  • Overview
  • How does it work?
  • Installation
  • Recovery
  • FAQ
  • Links
    • Github Repository
    • Extension Hub
Powered by GitBook
On this page
  • Workflow
  • Types of Strategies
  • Strategy 1
  • Strategy 2

How does it work?

A dive into how the extension technically works.

PreviousOverviewNextInstallation

Last updated 3 months ago

At a high-level, the Auto Stop Services extension monitors a Budget you define and will take action when the project cost has met the defined budget.

All Firebase services are usage based and, beyond their free tier limit, will generate cost to the project. The cost is monitored through a Billing Account where a project Budget is defined (in dollar terms).

A Budget can produce an Alert when specific thresholds (in percentage terms) are met - for example a $100 budget will default to a 50%, 90%, and 100% threshold. At each threshold the Budget will generate an Alert - though the indicates there may be several Alerts generated and not always when the threshold is met, but let's not worry about that.

There is a separate threshold defined in the Auto Stop Services extension, which we will call the Extension Threshold. This is the percentage threshold of your budget that must be met for the Auto Stop Services to actually kick into gear and stop your project services. This defaults to 100%, so if your project cost meets or exceeds your budget, your project services will stop.


Workflow

The general process is that a Budget raises an Alert which is fed into a Firebase Function (via a Pub/Sub topic). The Function will check that the threshold is met and will stop services if the threshold is met, otherwise nothing.

Case 1 - Alert raised, below Extension Threshold

Given we have a budget of $100 and our Extension Threshold is 100% When our project cost is $50 (i.e. 50% of budget) Then we do nothing

Case 2 - Alert raised at Extension Threshold

Given we have a budget of $100 and our Extension Threshold is 100% When our project cost is $100 (i.e. 100% of budget) Then we trigger a stop action, based on your strategy.

Case 3 - Alert raised above Extension Threshold

Given we have a budget of $100 and our Extension Threshold is 100% When our project cost is $110 (i.e. 110% of budget) Then we trigger a stop action, based on your strategy.

Note: There limitation of Billing on Google Cloud Platform around timeliness of cost information. There may be delays in billing information for services from a few hours to a day. This is completely unavoidable.


Types of Strategies

When a budget threshold is met, a stop action is required which tells the extension what to do if you have a cost blowout. Currently, this extension provides two strategies to choose from:

Strategy 1: Remove the billing account from your project, thereby freezing your project.

Strategy 2: Disables pre-defined Google Cloud Platform services in your project, thereby disabling specific parts of your project.

Recommended: Strategy 1 is highly recommended due for simplicity and ease of recovery.

Warning: Strategy 2 is dangerous and involves removal of project resources. Only experienced GCP and Firebase users should use this strategy.


Strategy 1

This strategy involves the extension disconnecting the Billing Account from your project. Conceptually, Google Cloud Platform will only allow you to use services if a Billing Account is connected to your project. So, if we remove this connection - voila!

What does this mean for your project?

  • All paid services within the project are immediately suspended. This includes compute instances, databases, and other cloud services that incur costs.

  • You can still access and view resources in the Google Cloud Console, but you cannot create new resources or use services that require billing.

  • Data stored in services like Cloud Storage, Firestore, and databases is preserved but may become inaccessible until billing is re-enabled.

  • Essential Google Cloud services remain available for managing projects and restoring billing, this includes IAM and Google Cloud Console access.

  • Any pending charges will still be billed. This includes those accrued before the billing account was removed, though no new charges will be generated until billing is re-established.

How do you recover from this approach?

Note: A Billing Account is a Google Cloud Platform concept. It is essentially an entity connected to your GCP/Firebase project which defines how you will pay for the services you utilise. If the link between these is cut, then GCP won't know how you will pay, thus will stop service usage.


Strategy 2

This strategy involves disabling specific Google Cloud Platform services. Firebase is inherently dependent on GCP services to deliver it's functional capabilities - thus if we disable a GCP service, naturally the Firebase service is disabled. This approach is dangerous as resources can be entirely removed and recovery complicated - hence this is only recommended for the advanced users.

What does this mean for your project?

  • The disabled service immediately stops all operations. For example, when disabling cloud functions, Firebase functions will no longer function and resources removed.

  • You cannot create new resources or view resources for disabled services. Attempts to do so will result in errors.

  • Existing resources for the disabled service may be removed. We should always assume complete deletion, this includes data (e.g. Firestore and Storage) and compute (Firebase Functions).

  • Essential Google Cloud services remain available unless explicitly disabled, this includes IAM and Google Cloud Console access.

  • Any pending charges will still be billed. This includes those accrued before the billing account was removed, though no new charges will be generated until billing is re-established.

How do you recover from this approach?

Note: A service in this context refers to a Google Cloud Platform API, such as Compute, Cloud Functions, Storage, etc. These APIs are denoted technically by their URI - e.g., compute.googleapis.com, cloudfunctions.googleapis.com

Auto Stop Services will receive the Alert via a Pub/Sub topic, and if it meets or exceeds the user defined threshold it will trigger a stop action based on your defined strategy (see below).

Recovery is incredibly simple. You manually reconnect your Billing Account to the project. A full guide on recovery for this strategy can be found in the section.

Recovery approach is highly dependent on which APIs you disable and your project setup. Broadly speaking, you will have to re-enable the APIs and potentially re-deploy part (or all) of your project. A full guide on recovery for this strategy can be found in the section.

Recovery
Recovery
Strategies
Google Cloud Platform documentation