How to Lower Costs for Long Running GCP Instances

Reduce costs for long-running GCP instances by finding them and applying committed use discounts. Follow this guide to lower your cloud expenses.

Patrick Londa
Author
Jul 22, 2022
 • 
 min read
Share this post

With GCP Compute Engine VM instances, you can readily scale virtual machines on-demand so that you can increase your CPU capacity as needed. Depending on what is needed and assigned to them, these instances take from seconds to hours to process all the operations.

Even though using on-demand GCP instances can be a fast way to get started, there are a few ways that you and your organization can start to lower your costs by reviewing instance performance.

In this article, we’ll focus on long running GCP instances. These are VMs that require a lot of time to run tasks. If you can forecast that these operations will continue and take significant time, you could save up to 70% on your cloud costs by purchasing GCP committed use discounts.

This guide will show you how to find long running virtual machines and achieve cost savings with a discounted GCP plan.

Blink Automation: Ensure Long Running GCP Instances are Reviewed
Blink + GCP
Try This Automation

Defining Long Running Compute Engine Instances

Long running virtual machine instances are active for long periods of time throughout the day and commonly perform tasks like background website scripts or complex computing calculations. Long running operations like these require your GCP Compute instances to use more time and resources. Therefore, they could quickly become very costly over multiple web sessions or VM instances.

There is no absolute value that labels an instance long running. Your organization can set a benchmark (like 90 days) and use that parameter to evaluate your instances. 

How to Find Long Running Instances

To find your long running instances, you can use the gcloud CLI to run the following command to find all instances running longer than 90 days:

gcloud compute instances list  --filter="creationTimestamp>-P90d"

Once you have your list of long running instances, you can use the Google Cloud console to see more details. On the “VM Instances” page, you can select a specific VM and view details about that instance’s performance in the Observability tab. On this Overview page, you’ll be able to see metrics like CPU utilization, Memory utilization, and Network Traffic. You can review this troubleshooting guide to check whether the long running instances are having performance issues or not.

You can also look at the processes of a specific VM instance to assess the operations that it is running and determine if they are regular jobs you would expect to continue into the future.

Source: Google Cloud Documentation, "Monitoring Processes on VMs"

Achieving Cost Savings with Committed Use Discounts

If your VM instances just need to take their time to run your applications and operations, you can reduce your costs by applying committed use discounts. While AWS has Reserved Instances (RIs) for predictable computing demands, GCP offers something similar known as Google Cloud Committed Use Discounts. This discount is made for users who are able to commit to GCP resource usage in exchange for up to a 70 percent savings on your VM instances.  

The main differences between this and AWS RIs is that committed use discounts are not automatically shared amongst multiple VMs, and it applies to the total number of vCPUs plus the amount of memory, instead of a specific VM or VM type. This makes it flexible for your machine-type-based projects. To apply the discount:

  1. Go to the "Committed Use Discounts" page in the Google Cloud console.
  2. Click on "Purchase Commitment" and then "New License Committed Use Discount" to purchase a new license commitment.
  3. Name your commitment and choose your region that you wish to apply it to.
  4. Choose a duration of commitment of either one or three years.
  5. Choose a license family.
  6. Choose the license type and quantity.
  7. Choose the number of licenses.
  8. Complete your purchase.

These discounts are restricted to instances with per CPU memory between 0.9GB and 6.5GB. 

Since you cannot share GCP Commitments across projects within a billing account, you may find yourself locked into the Project the discount was purchased for. Because of this, make sure you try to estimate the amount of time and usage your instances will require. Other than that, the discounts behave much like an RI for your long running GCP compute instances and can save you money on your VMs.

Automatically Detect Long Running Instances with Blink 

If you don’t have an automated system for finding long running instances, you may never consider the potential savings from switching to other discounted options.

Whether you want to aggregate reports on your CPU usage or navigate instance migrations, having an easy way to navigate the steps is critical.

With Blink, you can use this automation in the Blink library to manage and customize your performance optimization process.

Blink Automation: Ensure Long Running Instances are Reviewed in GCP
Blink Automation: Ensure Long Running Instances are Reviewed in GCP

You can run this automation by setting a max compute run time in days. When it runs, the automation will do the following steps:

  1. Run a check across your GCP account for instances that have been running longer than your max.
  2. Send a report with these instances to a specified email address.

This is a simple automation, but that makes it easy to customize. You can set it to run weekly or send the report instead to a Slack channel where you can take action.

These 5K pre-built automations in the library make it easy to scale your automation fast, or you can create new ones from scratch to perfect fit your needs.

Get started with Blink today to see how easy automation can be.

Expert Tip