top of page
  • bukunmi14

Learn Google Compute Engine

In the article on Cloud Computing, we introduced Virtual Machines as the basic unit of computing resources on the Cloud. We also mentioned that Virtual Machines(VMs) are offered as Infrastructure as a Service (IAAS) offering on public cloud platforms as users have the responsibility of setting up and configuring the resource before use.

In this blog post, we go on a deep dive into Virtual Machine on Google Cloud Platform(GCP). These are called Compute Engines. We will be exploring what they are, use cases, and the various options for their configuration on GCP.

Compute Engine is a service offered on GCP that allows users to create VMs and run instances. Compute Engine provides vCPU(virtual CPU), memory, and storage to users to run their applications.

An instance is a single virtual machine hosted on GCP and these instances run on Compute Engine Images. These images are templates that contain an operating system and libraries which are used to create boot disks that instances are spun up from.

GCP provides two image types for its customers. These are:

  • Public Images: Maintained and provided by Google, open-source communities or third party vendors. These images are available to all users by default. The public images include a range of operating systems, such as CentOS, Debian, Red Hat Enterprise Linux, Ubuntu, Windows Server, and others.

  • Custom Images: If the public image does not suit your needs you can create custom images. Custom images are created from boot disks and other existing images. Whatever custom image you create is only available in your project. Custom images give users the flexibility of configuring an operating system and installing software on each instance. This attribute comes in handy as you can always use the custom images to spin up VMs that require similar software without installing the software in every instance.

Types of Virtual Machines

The machine type describes the hardware attached to an instance which includes the CPU and the RAM. The machines types available on GCP are:

  • Predefined: These VMs are pre-optimized and maintained by Google. They are grouped into standard type(for balanced workload), high-memory machines, high-CPU machines, and shared-core type (for lower workloads that need to run for a long period).

  • Custom: In this machine type the hardware setup of the VMs is configured manually but the size of the RAM and CPU is capped by google. Custom machine type is recommended for users that have peculiar needs that can not be met by predefined machine types.

  • Preemptable: These are short-lived compute instances suitable for running applications that are fault-tolerant and can withstand interruptions. Preemptable VMs offer the same configuration options as the Normal VMs but they can be shut down at any instant by google and can only be active for a maximum of 24 hours. Preemptable VMs help to save substantial costs as they cost up to 80% less than normal VMs.

Instance Groups

Instance groups provide a stress-free way for users to manage a large number of VMs as a single entity. GCP provides the following types of instance groups:

  • Managed groups consist of identical VMs that are built from the same image template.

  • Unmanaged groups consist of different instances built with different image templates.

Regions and Zones

VMs run in Regions and Zones.

A region is a geographical location that is made up of zones. Each region has one or more zones. For example, the Eastern Asia region contains zones asia-east-1-a, asia-east-1-b, asia-east-1-c.

Zone: Consists of physical data centres that are closely coupled. They are located within regions and are linked by low-latency, high-bandwidth network connections. Zones within a region are physically separated by at least 100 miles.

Use Cases of Compute Engine

Compute Engine is suitable for the following instances:

  • Maximum control over your VM instances is needed

  • You want to choose the images that your VM instances run on

  • Custom libraries or software packages need to be installed on the VM

  • Detailed control over users of an instance is required.

Compute Engine provides the least amount of administration from GCP compared to other computing services. The user makes the choice of what image to use, the number of CPUs, the amount of memory to allocate, how to configure the boot disk and how to set up network configurations. Hence, users should be well aware that the more control Compute Engine gives the more the responsibility of setting up, configuring and managing the resource.

Setting up a Compute Engine Instance

To make use of Compute Engine you have to log in to your GCP account. If you don’t have one you can create it here Also, you have to enable billing, but if your account is new you will get a complimentary $300 worth of computing credit (as of the time of writing), so you can use that.

A Compute Engine instance can be created on GCP via both the Cloud Console GUI and the command line. We will be covering both methods in this article.

Creating and Configuring VMs using Cloud Console

Google Cloud Console is a web-based graphical user interface for creating, configuring,

and managing resources in Google Cloud.

To open Cloud Console Navigate to https// and login to your GCP account. The Compute Engine Icon can be found under the Compute section on the hamburger menu that holds all the resources on GCP.

After Selecting the Compute Engine icon, the next page shows the load down of all the services available in Compute Engine such as VM instances, Instance Groups, Images, Zones et al.

We want to set up a Compute Engine instance, so we select Compute Engine.

Next, we select VM instances and a new window pops up.

Click on the create icon and that will take us to the VM configuration page as shown in the image below.

Next, you specify the needed details for the configuration of the VM like

  • The Name of the VM instance, in our case we called the VM instance-1

  • The region and Zone where the VM will run, in our case we chose us-central1 as the region and us-central-a as the zone. You will want to choose a region that is geographically close to where your traffic will be coming from, or where you have the lowest latency. You don't need to guess this, you can make use of GCPING.

  • The machine type determines the type of VM whether they are predefined or custom. This also determines the number of CPUs and the size of the memory that will be attached to the VM. In our case, we chose the n1-standard-1 machine type with 1 vCPU and 3.75GB of Memory

  • The boot disk which contains the image and operating system that the VM will run on. Here you can choose the operating system you want to use. You can also choose the boot disk type, which can be either Standard Persistent Disk or SSD Persistent Disk. You can also specify the size of the disk.

After specifying all the needed configuration details we can now create our VM by clicking the create button at the bottom of the page.

The instance takes a few minutes before being created.A green check sign will show beside the name of our VM when it is successfully created as shown in the image below.

With that, we just created a VM called instance-1.

When you are done using your VM do not forget to stop or delete the instance using the trash icon at the top of the page to prevent incurring unnecessary cost.

The Stop command stops the instance, hence it is not consuming compute resources, so you will not be charged. The instance still exists and can be started again when you need it.

The delete command totally deletes the instance.

Creating and Configuring VMs using Cloud Shell

Cloud shell provides a Linux command line interface where you can run gcloud commands to perform operations on GCP.

To access Cloud Shell, click on the Cloud Shell button at the top right of the GCP console.

Click on continue when prompted and Cloud shell will open at the bottom of your screen.

To create an instance called instance-2, make use of the command shown below:

gcloud compute instances create  instance-2 --machine-type n1-standard-2 --zone us-central1-c

The command above contains the name of the instance, the machine type and the zone the VM will be created in. Click enter to run the command.

Looking at the top we can see that our instance-2 VM has been created.

We can also stop or delete instances from the cloud shell. The commands to do that are shown below:

gcloud compute instances stop instance-2 

gcloud compute instances delete instance-2

There you have it.

In this blog post, we have been able to lay the groundwork to get you started with Compute Engine, we gave an overview of how to set up a Compute Engine instance and all the various configurations needed.

In subsequent articles, we going to go further by showing how you can deploy an application using Compute Engine on GCP.

172 views0 comments

Recent Posts

See All


Post: Blog2_Post
bottom of page