GCP Optimization

GCP cost optimization comes in three main ways: adjusting Compute Engine machines in accordance with application requirements, switching to HDD storage and using Standard network tier instead of Premium.

#Compute Engine machine type

Machine types on GCP are highly customizable, thus it is advised to user n1-highcpu-x machines for CPU-intensive and n1-highmem-x for RAM-intensive loads.

To change a virtual machine's type, simply stop it and edit the machine type as stated in the official documentation.

#Storage optimization

HDD-based provisioned storage disks are 425% cheaper than SSD-based ones.

To migrate a machine from SSD to HDD, do the following steps:

  1. Stop the instance

  2. Create a snapshot of the boot disk attached to the machine

  3. Unassign the external IP address from the instance

  4. Create a new instance and specify the previously created snapshot as the source, assign the right external IP address and attach extra data disks if any

  5. Remove the old instance

  6. Enjoy the migrated machine with storage costs greatly reduced!

    Note: You may want to keep the disk snapshot for some time to be able to recreate the VM in case of any issues with the previously created one

#Network Tiers

To set the default tier for a project, follow this document.

The main way of optimizing network costs is creating external IP addresses and virtual machines with Standard Tier set from the start.