Resources - power2Cloud

5 ways to optimize your Compute Engine spending.

Written by power2Cloud | 27/06/24

In English, they say "a penny saved is a penny earned," recalls Maciej Strzelczyk, Developer Programs Engineer, Google Cloud Platform.

"Whether you are a small business that has recently started using the cloud, or you are part of a large company that wants to optimize its expenses, this guide is for you, here are 5 ways to save on your costs. 

Compute Engine offers a number of opportunities to reduce costs, optimize infrastructure with some beneficial discounts and suggestions." Let's get started!

 

1. Review the current spending structure

Before embarking on a journey to optimize your Compute Engine budget, it would be wise to understand what your facility's current cost situation is so that you can make sensible decisions!  

The billing panel of the Google Cloud Console specifies the exact expense items, each is tracked with an individual SKU. So you can get the big picture of your organization's finances and analyze the costs of using a specific product for a particular project. 

A more in-depth analysis of expenses can help you identify resources you no longer need but are still paying for. After all, there is no better way to save money than to not spend it!

 

2. Check automatic recommendations

Have you noticed the light bulb icon next to some of your machines on the page that lists your virtual machines? 

These are Google Cloud's automatic recommendations on actions to take to save money.  

These helpful tips come from Recommendation Hub, a new tool intended to help you manage your projects in the following categories: 

    • Costs
    • Security
    • Performance
    • Reliability
    • Management 
    • Sustainability. 

The recommendation system has an idea related to the resources committed to your VMs and can suggest actions for you to consider. The goal is to help you reduce costs without affecting fleet performance.

 

The system can suggest actions such as changing the machine type  (i.e. from n1 to e2), resizing the machine according to its usage, etc.

Once you click on a recommendation, you receive a summary of the suggested change, with estimated cost savings.  You can choose whether to apply it or not. 

Remember that changes to VM characteristics require restarting the instance

 

3. Check storage type

Each virtual machine in your fleet must have at least one persistent disk attached. The disks in Google Cloud are of different types and offer different performance and features. 

The types available are:

    • Hyperdisk, designed for the most demanding mission-critical applications, Hyperdisk offers a scalable, high-performance storage service with a full suite of persistence and data management capabilities.
    • Hyperdisk Storage Pool. Pre-purchased collection of capacity, throughput, and IOPS that can be provided to applications as needed.
    • Persistent Disk. The default storage solution for virtual machines. It can be zonal or regional. It is available in four variants:
    • Standard. Equivalent to an HDD drive in the desktop computer. Offers the cheapest storage in exchange for lower I/O speeds.
    • SSD, a speed-oriented solution that provides excellent I/O performance, but at a higher cost per GB.
    • Balanced, the middle ground between "Standard" and "SSD"; the default solution for new computing instances.
  • Extreme for the most demanding workloads. It allows you to control not only disk size, but also IOPS.
  • Local SSD. An SSD drive physically attached to the host on which the virtual machine runs. Extremely fast, but not persistent.

Let's focus on the Persistent Disk storage family, as it is the most widely used. 

When creating a new virtual machine, the default disk type is the Balance disk, which, as the name implies, offers a good balance between performance and cost.  

Although suitable for many scenarios, it may not be the best option for all applications. For example, stateless applications that are part of auto-scaling deployments and store all relevant information in a cache or external database do not require fast disk I/O. 

These applications are ideal for changing the disk type to Standard, which can be up to three times cheaper per GB than Balanced disk (depending on region).

You can get a list of disks used in the project with: gcloud compute disks list --format="table(name, type, zone, sizeGb, users)".

To change the disk type, you need to clone it and change the virtual machines that use it, so you can start using the new disk. 

 

4. Clear empty disk space

With regard to storage, the type of disk is not the only factor affecting cost. Disk usage can also play an important role in the budget. 

If there is a 100 GB persistent disk in your project, you will pay for the 100 GB, regardless of whether you are using 20%, 70%, or 100% of this space. 

Even if your application does not use persistent disks for data storage, you should still pay close attention to boot disks. 

Consider whether your stateless application really requires a disk with more gigabytes of available space, then consider trimming these disks to fit the actual use. 

People like round figures so they often create 20 GB disks even though they only need 12 GB. Be closer to your machine to save money!

 

5. Committed Use Discount*(CUD)

This advice applies to many other products besides Compute Engine. 

If you know that you will be using a number of virtual machines for at least one year (or three years), you can get a steep discount!  

Using a set of CUDs can achieve much lower prices for vCPU, memory, GPU, local SSD, single-tenant nodes, and software licenses. 

With Flex's CUDs, there is also no need to limit vCPU and memory commitments to a single project, region, or series of machines.

These discounts are available for many Google Cloud products. If you are happy with Google Cloud and don't plan to abandon it anytime soon, consider using CUDs whenever possible for significant savings. 

In the case of calculation, you can purchase CUDs directly from the Google Cloud Console.