2.3 Resource Management
2.3 Resource Management
In this module, we will cover Resource Management. Resources in Google Cloud are
billable, so managing them means controlling cost. There are several methods in
place for controlling access to the resources, and there are quotas that limit
consumption.
In most cases, the default quotas can be raised on request, but having them in place
provides a checkpoint or a chance to make sure that this really is a resource you
intend to consume in greater quantity.
3
Agenda
Resource Manager
Quotas
Labels
Billing
Lab
In this module, we will build on what we learned in the IAM module. First, I will provide
an overview of the Resource Manager. Then, we will go into quotas, labels, and
names. Next, we will cover billing to help you set budgets and alerts. To complete
your learning experience, you will get to examine billing data with BigQuery in a lab.
Resources
VM instance
The resource manager lets you hierarchically manage resources by project, folder,
and organization. This should sound familiar because we covered it in the Cloud IAM
module. Let me refresh your memory:
Policies contain a set of roles and members, and policies are set on resources. These
resources inherit policies from their parent, as we can see on the left. Therefore,
resource policies are a union of parent and resource.
Also, keep in mind that if a parent policy is less restrictive, it overrides the more
restrictive resource policy.
Resource Manager lets you hierarchically manage
resources
Identity and Access
Management
GCP Billing and Resource
Monitoring
Although IAM policies are inherited top-to-bottom, billing is accumulated from the
bottom up, as we can see on the right. Resource consumption is measured in
quantities, like rate of use or time, number of items, or feature use. Because a
resource belongs to only one project, a project accumulates the consumption of all its
resources.
Each project is associated with one billing account, which means that an organization
contains all billing accounts. Let’s explore organizations, projects, and resources
more.
Organization node is root node for GCP resources
[email protected] example.com
Organization
Admin
Create
Just to reiterate, an organization node is the root node for all Google Cloud Platform
resources. This diagram shows an example where we have an individual, Bob, who is
in control of the organizational domain through the organization admin role. Bob has
delegated privileges and access to the individual projects to Alice by making her a
project creator.
Project accumulates the consumption of all its
resources
● Track resource and quota usage
○ Enable billing
○ Manage permissions and credentials
○ Enable services and APIs
● Projects use three identifying attributes:
○ Project Name
○ Project Number
○ Project ID, also known as Application ID
Because a project accumulates the consumption of all its resources, it can be used to
track resources and quota usage. Specifically, projects let you enable billing, manage
permissions and credentials, and enable service and APIs.
To interact with Cloud Platform resources, you must provide the identifying project
information for every request.
You can find these three identifying attributes on the dashboard of your GCP Console
or by querying the Resource Manager API.
Resource hierarchy Billing and reporting
is per project.
Resources are global, regional, or zonal.
● Images
Global ● Snapshots
Networks
●
Project-1 Project-2
Regional Regional
instance instance
● External IP
Zonal Zonal Addresses
Finally, let’s talk about the resource hierarchy. From a physical organization
standpoint, resources are categorized as global, regional, or zonal.
However, regardless of the type, each resource is organized into a project. This
enables each project to have its own billing and reporting.
Agenda
Resource Manager
Quotas
Labels
Billing
Lab
Now that we know that a project accumulates the consumption of all its resources,
let’s talk about quotas.
Proprietary + Confidential
● How quickly you can make API requests in a project: rate limits
○ 5 admin actions/second (Cloud Spanner)
All resources in Google Cloud are subject to project quotas or limits. These typically
fall into one of the three categories shown here:
● How many resources you can create per project. For example, you can only
have 15 VPC networks per project.
● How quickly you can make API requests in a project or rate limits. For
example, by default, you can only make 5 administrative actions per second
per project when using the Cloud Spanner API.
● There also regional quotas. For example, by default, you can only have 24
CPUs per region.
Given these quotas, you may be wondering, how do I spin up one of those 96-core
VMs?
As your use of Google Cloud expands over time, your quotas may increase
accordingly. If you expect a notable upcoming increase in usage, you can proactively
request quota adjustments from the Quotas page in the Cloud Console. This page will
also display your current quotas.
Quotas also prevent billing spikes or surprises. Quotas are related to billing, but we
will go through how to set up budgets and alerts later, which will really help you
manage billing.
Finally, quotas force sizing consideration and periodic review. For example, do you
really need a 96-core instance, or can you go with a smaller and cheaper alternative?
It is also important to mention that quotas are the maximum amount of resources you
can create for that resource type as long as those resources are available. Quotas do
not guarantee that resources will be available at all times. For example, if a region is
out of local SSDs, you cannot create local SSDs in that region, even if you still had
quota for local SSDs.
Agenda
Resource Manager
Quotas
Labels
Billing
Lab
Projects and folders provide levels of segregation for resources, but what if you want
more granularity? That’s where labels come in.
Labels are a utility for organizing GCP resources
Labels are a utility for organizing GCP resources. Labels are key-value pairs that you
can attach to your resources, like VMs, disks, snapshots and images. You can create
and manage labels using the GCP console, gcloud, or the Resource Manager API,
and each resource can have up to 64 labels.
For example, you could create a label to define the environment of your virtual
machines. Then you define the label for each of your instances as either production or
test. Using this label, you could search and list all your production resources for
inventory purposes.
Labels can also be used in scripts to help analyze costs or to run bulk operations on
multiple resources. The screenshot on the right shows an example of 4 labels that are
created on an instance.
Use labels for ...
● Components ● State
component: redis state:inuse
component: frontend state:readyfordeletion
● Environment or stage
environment: prod
environment: test
Labels, we just learned, are user-defined strings in key-value format that are used to
organize resources, and they can propagate through billing.
Tags, on the other hand, are user-defined strings that are applied to instances only
and are mainly used for networking, such as applying firewall rules.
For more information about using labels, see the links section of this video
[https://cloud.google.com/resource-manager/docs/using-labels]
Agenda
Resource Manager
Quotas
Labels
Billing
Lab
Because the consumption of all resources under a project accumulates into one
billing account, let’s talk billing.
Budgets and email alerts
To help with project planning and controlling costs, you can set a budget. Setting a
budget lets you track how your spend is growing toward that amount. This screenshot
shows the budget creation interface:
● First, you set a budget name and specify which project this budget applies to.
● Then, you can set the budget at a specific amount or match it to the previous
month's spend.
● After you determine your budget amount, you can set the budget alerts. These
alerts send emails to billing admins after spend exceeds a percent of the
budget or a specified amount.
In our case, it would send an email when spending reaches 50%, 90%, and 100% of
the budget amount. You can even choose to send an alert when the spend is
forecasted to exceed the percent of the budget amount by the end of the budget
period.
You are receiving this email because you are a Google Cloud Platform, Firebase, or API
customer.
This is an automated notification to inform you that the project: arch-gce has exceeded
50% of the monthly budget of $500.00.
You are receiving this message because there is an alert configured on this project's budget.
To disable this alert or modify the budget's threshold, please edit your budget.
Here is an example of an email notification. The email contains the project name, the
percent of the budget that was exceeded, and the budget amount.
Labels can help you optimize GCP spend
Another way to help optimize your GCP spend is to use labels. For example, you
could label VM instances that are spread across different regions. Maybe these
instances are sending most of their traffic to a different continent, which could incur
higher costs. In that case, you might consider relocating some of those instances or
using a caching service like Cloud CDN to cache content closer to your users, which
reduces your networking spend.
I recommend labeling all your resources and exporting your billing data to BigQuery to
analyze your spend. BigQuery is Google’s scalable, fully managed Enterprise Data
Warehouse with SQL and fast response times.
Creating a query is as simple as shown in this screenshot, which you will explore in
the upcoming lab.
Visualize Google Cloud spend with Data Studio
Billing Dashboard
Google
Data Studio
You can even visualize spend over time with Data Studio. Data Studio turns your data
into informative dashboards and reports that are easy to read, easy to share, and fully
customizable. For example, you can slice and dice your billing reports using your
labels.
Demo
Billing Administration
Philipp Maier
In the upcoming lab you will examine billing data that we exported for you. Let me
show you how to export billing data and demonstrate other common activities that a
billing administrator performs. These actions cannot be performed in the qwiklabs
environment because of security restrictions; therefore, I am going to walk you
through them as a demo.
Demo
That’s how it easy it is to administer billing in GCP. A billing administrator can set up
accounts and run reports, which are ordinary tasks. But becoming familiar with the
available options and seeing how these tasks are performed reduces the chances of
confusion. For example, you now know that reports can be generated in JSON or in
CSV format.
Now, more sophisticated processing or filtering of data occurs after the billing is
exported, as you will explore in the next lab.
Lab
Examining Billing Data
with BigQuery
In this lab, you will sign in to BigQuery and create a dataset. In this dataset, you will
create a table by importing billing data that is stored in a Cloud Storage bucket. Next,
you will run simple queries on the imported data, and then you will run more complex
queries on a larger dataset.
Lab review
Examining Billing Data
with BigQuery
In this lab, you imported billing data into BigQuery that had been exported as a CSV
file. You first ran a simple query on that data.
Next, you accessed a shared dataset containing more than 22,000 records of billing
information. You then ran a variety of queries on that data to explore how you can use
BigQuery to gain insight into your resources’ billing consumption.
If you use BigQuery on a regular basis, you'll start to develop your own queries for
searching out where resources are being consumed in your application. You can also
monitor changes in resource consumption over time. This kind of analysis is an input
to capacity planning and can help you determine how to scale up your application to
meet growth or scale down your application for efficiency.
Proprietary + Confidential
Review:
Resource Management
In this module, we covered the Cloud Resource Manager and went into quotas,
labels, and billing. Then we examined billing data with BigQuery in a lab.