Skip to content

You are viewing a free preview of this lesson.

Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.

Compute Engine Overview

Compute Engine Overview

Google Compute Engine is the Infrastructure as a Service (IaaS) component of Google Cloud Platform. It lets you create and run virtual machines on Google's infrastructure, giving you full control over the operating system, software stack, and network configuration while Google manages the underlying physical hardware, power, cooling, and data-centre security.


What is Compute Engine?

Compute Engine provides scalable, high-performance virtual machines that run in Google's data centres around the world. Each VM instance behaves like a dedicated physical server — it has its own vCPUs, memory, storage, and network interfaces — but it is provisioned in seconds from shared physical hardware using Google's custom hypervisor.

Key Characteristics

Characteristic Description
On-demand Create and delete VM instances in seconds
Global Available in 40+ regions across 6 continents
Pay-per-second Billed per second with a 1-minute minimum
Full control You manage the OS, middleware, and applications
IaaS Google manages the physical infrastructure; you manage everything above the hypervisor
Sustained-use discounts Automatic discounts for VMs that run for a significant portion of the month

When to Use Compute Engine

Compute Engine is the right choice when you need full control over the computing environment. Common use cases include:

Lift and Shift Migration

Migrating existing on-premises workloads to the cloud with minimal changes. If you have a Linux server running Nginx or a Windows Server running IIS, you can replicate the same environment as a Compute Engine VM.

Custom Software Stacks

Applications that require specific kernel versions, custom drivers, or non-standard runtime environments that managed services like App Engine or Cloud Run cannot support.

High-Performance Computing (HPC)

Scientific simulations, financial modelling, and rendering workloads that require large numbers of cores, high-speed networking, and GPU or TPU accelerators.

Enterprise Applications

Traditional enterprise applications such as SAP, Oracle databases, Microsoft SQL Server, and custom line-of-business software that require dedicated compute resources.

Development and Testing

Quickly spin up and tear down environments for development, testing, or CI/CD pipelines. Developers can create VMs that mirror production configurations and delete them when testing is complete.


Creating Your First VM

You can create a VM using the Google Cloud Console, gcloud CLI, REST API, Terraform, or Deployment Manager. Here is a simple example using the gcloud CLI:

# Create a Linux VM instance
gcloud compute instances create my-vm \
  --zone=europe-west2-a \
  --machine-type=e2-medium \
  --image-family=debian-12 \
  --image-project=debian-cloud \
  --boot-disk-size=20GB \
  --boot-disk-type=pd-balanced

This command creates:

  • A VM instance named "my-vm" in the europe-west2-a zone
  • An e2-medium machine type (2 shared vCPUs, 4 GB RAM)
  • A Debian 12 boot disk with 20 GB of Persistent Disk storage
  • A default network interface with an ephemeral external IP

Creating a Windows VM

gcloud compute instances create my-windows-vm \
  --zone=europe-west2-a \
  --machine-type=n2-standard-4 \
  --image-family=windows-2022 \
  --image-project=windows-cloud \
  --boot-disk-size=50GB \
  --boot-disk-type=pd-ssd

Components of a Compute Engine VM

When you create a VM, several resources come together:

Resource Purpose
VM Instance The compute resource itself
Boot Disk Persistent disk containing the operating system
Additional Disks Optional data disks (Persistent Disk or Local SSD)
Network Interface Connects the VM to a VPC network
VPC Network & Subnet The private network the VM resides in
External IP Optional — provides internet-accessible IP address
Firewall Rules Control inbound and outbound traffic

Each of these resources has its own lifecycle, configuration, and billing, so understanding them is essential for effective cost and resource management.


VM Lifecycle and Billing

Compute Engine VMs can be in several states, and billing depends on the state:

State Compute Charges Storage Charges
RUNNING Yes Yes
SUSPENDED No (small per-instance charge for preserving memory) Yes
STOPPED (terminated) No Yes (disks still exist)
DELETED No No (if disks also deleted)

Important: Stopping a VM from within the guest OS (e.g., sudo shutdown -h now) will terminate the instance but the persistent disks remain and continue to incur charges. To stop billing for both compute and storage, you must delete the VM and its disks.

# Stop a VM (stops compute charges, disk charges continue)
gcloud compute instances stop my-vm --zone=europe-west2-a

# Delete a VM and its boot disk
gcloud compute instances delete my-vm --zone=europe-west2-a --delete-disks=all

Connecting to a VM

Linux VMs — SSH

gcloud compute ssh my-vm --zone=europe-west2-a

Google Cloud manages SSH keys automatically via OS Login or project/instance metadata.

Windows VMs — RDP

Use the gcloud CLI to set or reset the Windows password, then connect via Remote Desktop Protocol (RDP) on port 3389.

gcloud compute reset-windows-password my-windows-vm --zone=europe-west2-a

Identity-Aware Proxy (IAP) Tunnelling

For secure access without exposing external IPs, use IAP TCP forwarding. It creates an encrypted tunnel from your local machine to the VM through Google's identity-aware proxy, eliminating the need for a public IP.

gcloud compute ssh my-vm --zone=europe-west2-a --tunnel-through-iap

Supported Operating Systems

Compute Engine supports a wide range of operating systems via public images:

Linux: Debian, Ubuntu, CentOS, Red Hat Enterprise Linux (RHEL), SUSE Linux Enterprise, Rocky Linux, Fedora CoreOS, Container-Optimized OS (COS), and many more.

Windows: Windows Server 2016 through 2025, including Server Core editions and SQL Server images.

You can also bring your own custom images or import VMs from on-premises environments.


Summary

Google Compute Engine provides full infrastructure-level control in the cloud with per-second billing, sustained-use discounts, and a global footprint. VMs can be created in seconds, support both Linux and Windows, and integrate deeply with other GCP services. Understanding VM lifecycle states is essential for managing costs — always stop or delete VMs you are not using. In the next lesson, we will explore machine types and families to help you choose the right configuration for your workload.