GCP Billing & Cost Management

Asrın Andırın
11 min readSep 24, 2023

Introduction

In this article, I’ll break down how Google Cloud Platform handles costs and billing. I’ll explain how to read your bill and set up ways to manage costs. I have divided this article into parts and we will proceed by examining all the key concepts one by one.

My goal is to help you use the platform confidently without spending more than you need to.

Key Concepts

  • How GCP Handles Billing ?
  • Billing Account & Associated IAM Roles
  • Billing Alerts, Budgets
  • Billing Reports
  • FinOps Hub
  • Tools to Reduce Costs
  • Always Free Products
  • Specific Cases/Tips (Bonus)

GCP primarily uses a pay-as-you-go billing approach. This means you pay for what you use. Once you consume a service, GCP keeps track of your usage, and you’re billed accordingly.

Example Consumes

  • Compute Engine: Billed for VM instances by the second (with a 1-minute minimum), based on the type of instance and the region.
  • Storage: Costs vary by storage type (like Persistent Disk, Cloud Storage, etc.) and the amount of data stored.
  • Data Transfer: You’re typically charged for data going out of GCP to the internet or to other cloud providers.

Billing Account

To use GCP services, you’ll need a billing account, which will be associated with a source of payment, such as a credit card or bank account. Your GCP projects will be linked to this billing account.

Beyond the description, let’s explore the importance of Billing Account,

  • The primary purpose of a billing account is to keep track of the costs incurred from using GCP services. Every service has its pricing model, and without a structured billing system, it would be challenging to manage and monitor the costs.
  • Large organizations may run multiple projects on GCP. By linking multiple projects to a single billing account, organizations can consolidate their expenses and manage them more effectively.
  • By using Google Cloud’s Identity and Access Management (IAM), you can control who has access to the billing account and what they can do with it. This ensures that only authorized personnel can view and manage the costs.
  • Billing accounts, in conjunction with other GCP resource management tools like projects, folders, and labels, allow organizations to structure their resources in a way that mirrors their operational and organizational needs.

To give an example for beginner level users:

When you open a trial account, the $300 credit given to you by Google is defined to your billing account. Also this billing account is where you define your credit card when you first create this trial account.

IAM Roles Associated with Billing Account

There are 4 important roles you need to know when authorizing the people you want to authorize regarding budget control.

⚠️ When managing IAM roles for billing, it’s essential to follow the principle of least privilege, meaning giving users only the permissions they absolutely need.

Billing Account Administrator: Users with this role can manage all aspects of billing accounts. This includes:

  • Changing settings.
  • Associating and disassociating projects.
  • Managing payment methods.
  • Setting budgets.
  • Viewing usage and cost details.

Billing Account User: This role allows users to associate projects with billing accounts. However, it doesn’t permit other management activities like setting budgets or changing the payment method.

Billing Account Viewer: Users assigned this role can view billing account details, but they cannot make changes to the account or associate projects with it.

Billing Budget and Report User: With this role, users can view and manage budgets and alerts. They can also view billing account details and reports.

Billing Alerts & Budgets

One of the most significant risks of using cloud services is unexpected costs. Billing alerts help notify users or organizations when their spending reaches or exceeds predefined thresholds, enabling timely intervention to prevent overspending.

Regular notifications about costs can prompt users or teams to analyze their cloud usage patterns and identify opportunities for cost savings, such as turning off unused resources or shifting to more cost-effective services.

Budgets & Alerts can be set up into each Billing Account.

When you decide to define Budgets & Alerts, you see It consist of 3 stages, (I don’t explain all buttons/forms, I believe It’s clear)

  • By default, billing admins will notify when you reach each threshold.
  • You can use Cloud Monitoring Notification Channels to notify when you reach each threshold.
  • You can connect to Cloud Pub/Sub topic to this budget.

After you setup alerts & budgets, you are more safe to go into cloud.

Billing Reports

The Cloud Billing Reports page lets you view your Google Cloud usage costs at a glance and discover and analyze trends. The Reports page displays a chart that plots usage costs for all projects linked to a Cloud Billing account.

Here is an example view of Billing Reports.

  • The report breaks down costs by product, SKU (Stock Keeping Unit), project, location, and other dimensions, providing a granular view of where expenses are coming from.
  • With the insights from the Billing Report, organizations can identify which services or resources are the most expensive and make decisions to optimize or reduce those costs. The Billing Report also allows users to see how their costs are trending over time. This can highlight growth areas or alert to unexpected spikes in usage and spending.
  • Sudden, unexpected changes in costs can be a sign of operational issues, misconfigurations, or even security breaches. The Billing Report can help in quickly spotting such anomalies.

By analyzing past spending patterns, organizations can better forecast future cloud expenses and set realistic budgets.

FinOps Hub

The FinOps hub helps you monitor and communicate your savings, explore cost optimization opportunities, and plan your goals. It presents all active savings and optimization opportunities in one dashboard, generated automatically based on historical usage data from Cloud Billing and Recommender.

FinOps hub Dashboard

The FinOps hub dashboard summarizes your current cost optimizations and introduces recommended optimizations from Google Cloud. It provides information based on historical data collected.

FinOps Score

The FinOps Score helps you gauge how well you use Google Cloud tools to monitor and save costs, and how to optimize costs further. It is calculated based on the following optimization best practices:

If you apply all principles to saving cost, your FinOps score should be above 4.

Don’t worry about “3 year CUD” recommendations. (If you only see them you have perfect cost management in your environment because there is nothing to do more.)

Tools to Reduce Costs

Right Sized VM’s

Google Cloud Platform offers tools like the “Compute Engine Rightsizing Recommendations” that analyze the utilization metrics of VM instances and then provide recommendations on the ideal machine type to fit the workload.

How machine type recommendations work

Compute Engine monitors the CPU and memory utilization of running VMs and makes recommendations using the last 8 days of data.

You can see the details of recommendations in GCE dashboard.

Sustained VM’s

The term “sustained VMs” is not a distinct type of VM in GCP, but rather it refers to the sustained usage of VMs and the associated automatic discounts users receive for running specific Compute Engine resources for a significant portion of the billing month.

One of the primary advantages of Sustained Use Discounts is that they are applied automatically. Users don’t need to make upfront commitments or reservations.

The discount increases with usage. For instance :

  • 0–25% of the month: No discount.
  • 25–50% of the month: 20% discount on the hourly cost for the usage above 25%.
  • 50–75% of the month: 40% discount on the hourly cost for the usage above 50%.
  • 75–100% of the month: 60% discount on the hourly cost for the usage above 75%.

Sustained Use Discounts apply to on-demand, self-managed VM instances that run for a significant portion of the billing month. They do not apply to VM instances that are part of a committed use contract, preemptible instances, or sole-tenant nodes.

Committed Use Discounts

Committed Use Discounts refer to the reduced pricing offered in exchange for committing to use specific Compute Engine resources for a set period. When you make such a commitment, you agree to pay for the resources (like vCPUs, memory, GPUs) for the length of the commitment, usually 1 or 3 years.

Unlike some other cloud providers that offer reserved instances with an upfront payment option, GCP’s Committed Use Discounts do not necessitate any upfront fees. You commit to a monthly payment for the duration of the term. The commitments are made on a regional basis.

There are 2 types of CUD

Spend-based CUD’s

Spend-based committed use discounts apply when you commit to spend a specific amount measured in dollars per hour, for one or three years.

  • The Cloud Billing Account that purchased the spend-based CUDs can apply the discount to different projects under it.
  • The discount applies to Google Cloud Run, Cloud Spanner, Cloud SQL, Compute Engine, Google Cloud VMware Engine, Memorystore, and Google Kubernetes Engine (GKE).
  • Usage that exceeds the committed threshold is charged at the undiscounted, on-demand rate.

Resource-based CUD’s

Resource-based committed use discounts apply when you commit to use a fixed amount of Compute Engine resources in a specific region over a 1- or 3-year duration.

  • Deliver up to 55% savings for a 3-year term or 37% for a 1-year commitment.
  • Only apply to GCP’s Compute Engine service.
  • You purchase them in the context of a specific project, not that of a Cloud Billing Account.

Example Saving

Free Tier Products

These are specific resources or quotas you can use for free every month, even after the 3-month free trial ends.

https://cloud.google.com/free

  • Compute Engine: 1 f1-micro instance (in specific regions) and 30 GB-months of Standard persistent disk storage.
  • Cloud Storage: 5 GB-months of Regional storage in specific regions, including 5,000 Class A and 50,000 Class B operations per month.
  • Cloud Pub/Sub: 10 GB of messages per month.
  • Cloud Functions: 2 million invocations, 400,000 GB-seconds, 200,000 GHz-seconds of compute time, and 5 GB network egress per month.
  • Google Kubernetes Engine (GKE): While the basic use of GKE is free, you would still incur costs for the compute resources (like worker node VMs) that you use.
  • Cloud Firestore: 1 GB storage, 50,000 reads, 20,000 writes, and 20,000 deletes per day.
  • Cloud Run: 2 million requests per month, 360,000 GB-seconds, 180,000 GHz-seconds of compute time, and 1 GB network egress.
  • BigQuery: 1 TB of querying per month and 10 GB of storage.
  • Google Drive: 15 GB of storage.
  • Cloud Build: 120 build-minutes per day.
  • Cloud Shell: Always free access to Cloud Shell, including 5 GB of persistent disk storage.
  • Stackdriver Logging: 50 GB of logs with 7 days retention.
  • Stackdriver Monitoring: Always free for up to a certain number of metrics and time series.

Benefits

By using free tier products, especially for individuals new to cloud computing or GCP, the free tier provides an opportunity to learn by doing.

Startups, developers, and businesses can prototype solutions, test new ideas, or learn about the features and capabilities of different GCP services without a financial commitment.

You can test the performance of specific services to see if they meet your needs. This is particularly useful when comparing the capabilities of GCP with other cloud providers.

The free tier lets users understand the GCP ecosystem’s integrations, interfaces, and interplay between various services, which can be valuable when planning larger, paid deployments.

Specific Cases (Bonus)

What if you disable billing account for a project ?

  • Disabling billing for a project will stop all billable services associated with that project. These services will no longer function, leading to potential downtimes or service disruptions.
  • Even though billable services are shut down, the resources themselves (like VM instances, data storage, etc.) are not automatically deleted. They will, however, be in a “stopped” or “inactive” state.
  • Free tier quotas won’t apply to the project anymore. After disabling billing, if you want to use a service that has a free tier, you’ll have to enable billing again.
  • If your project involves data egress or external API requests, disabling billing may cause these processes to fail because these typically come with associated costs.
  • Some GCP services might have limitations when not associated with a billing account, even if they have a free tier.

What if you need to transfer your project to a different billing account ?

  • If you need to move a project from one billing account to another (like during internal reorganization or post-acquisition), GCP allows you to change the billing account associated with a project.

What if your payments fails ?

  • If a payment fails (e.g., due to an expired credit card), GCP will retry charging the payment method. If the issue persists, it may temporarily suspend the billing account, affecting the associated projects.

What if you want to change your billing account currency ?

  • When you set up a billing account, you choose a currency for it. It’s crucial to note that once selected, the currency cannot be changed for that billing account.

Use labels for detailed Billing Report

  • Once resources are labeled, the Billing Report can break down costs based on these labels. This can give a more granular insight into where costs are being accrued. For instance, if you’ve labeled resources by department or project, you can see exactly how much each department or project is costing you in cloud resources. Also by assessing costs based on labels, organizations can pinpoint underutilized or overpriced resources specific to a project or team. This granularity can lead to more targeted resource optimization strategies.

Use Pub/Sub for Budgets & Alerts

  • When a budget threshold is reached, GCP can send a message to a Pub/Sub topic. This Pub/Sub event can then trigger automated actions, like shutting down Compute Engine instances, scaling down services, or disabling billing (though this is extreme and not often recommended).
  • By incorporating Cloud Functions or Cloud Run with the Pub/Sub messages, you can apply conditional logic to alerts. For example, you might decide to shut down non-essential services if a budget threshold is hit but only if the workload is below a certain level.

Combination with Committed Use Contracts

  • It’s a common misconception that SUDs and Committed Use Contracts can’t be combined. While it’s true for the same instance, if you have a Committed Use Contract for some of your VMs, any additional, non-committed VMs can still benefit from SUDs.

In conclusion, effective cost and billing management is crucial for maximizing the benefits of any cloud platform. As businesses scale and evolve, their cloud expenses can become complex and challenging to manage. However, with a thorough understanding of GCP’s cost management tools, a strategic approach to resource allocation, and proper budget & alert system, organizations can ensure they are getting the most value for their investment. By staying proactive, leveraging discounts, and keeping an eye on emerging best practices, businesses can confidently navigate the cloud landscape, striking the right balance between performance and cost.

--

--