Compute Engine Fundamentals: Machine Types, Images, Disks, Startup Scripts, Spot VMs and Sole-Tenant Nodes

Google Cloud Platform Architect 55 min min read Updated: Nov 17, 2026 Beginner
Compute Engine Fundamentals: Machine Types, Images, Disks, Startup Scripts, Spot VMs and Sole-Tenant Nodes
Beginner Topic 1 of 4

What Is Compute Engine?

Compute Engine (GCE) gives you virtual machines running on Google's infrastructure. It is IaaS: you choose the size and operating system, and you manage the software.

Machine Families

FamilySeries examplesBest for
General purposeE2 (low cost), N2, N4, C4, Tau T2DWeb servers, apps, small databases. Start here
Compute optimizedC2, H3High-performance computing, gaming, batch
Memory optimizedM-seriesIn-memory databases like SAP HANA
Storage optimizedZ3Large local SSD workloads
Accelerator optimizedA-series, G-series (GPUs)Machine learning and graphics
  • Names look like e2-standard-4: family e2, shape standard, 4 vCPUs
  • Shapes: standard (about 4 GB per vCPU), highmem (8 GB), highcpu (1 GB)
  • Custom machine types let you pick exact vCPU and memory so you do not pay for extra
  • Shared-core types (e2-micro, e2-small) are cheap for tiny jobs
bash gcloud compute machine-types list --zones=asia-south1-a --filter="name~^e2-standard" gcloud compute instances create custom-vm --zone=asia-south1-a --custom-cpu=3 --custom-memory=10GB --custom-vm-type=n2

Images and Boot Disks

  • An image is a template with the operating system (Debian, Ubuntu, Windows, Rocky and more)
  • A custom image is made from your own configured disk. Group versions in an image family
  • The boot disk is a Persistent Disk or Hyperdisk created from the image

Launch a Web Server With a Startup Script

bash cat > startup.sh <<'EOF' #!/bin/bash apt-get update && apt-get install -y nginx echo "Hello from $(hostname)" > /var/www/html/index.html EOF gcloud compute instances create web-1 --zone=asia-south1-a --machine-type=e2-small \ --image-family=debian-12 --image-project=debian-cloud --tags=http-server \ --metadata-from-file=startup-script=startup.sh gcloud compute firewall-rules create allow-http --allow=tcp:80 --target-tags=http-server --source-ranges=0.0.0.0/0 gcloud compute instances describe web-1 --zone=asia-south1-a --format="get(networkInterfaces[0].accessConfigs[0].natIP)"
  • Metadata are key-value settings available to the VM at metadata.google.internal
  • Network tags link firewall rules to VMs
  • VMs get an attached service account so code needs no keys

Pricing Options for VMs

OptionIdeaUse for
Standard (on-demand)Pay per second (minimum 1 minute)Normal workloads
Spot VMsSpare capacity at a large discount. Google can stop them any time (30-second warning). No maximum runtimeBatch, CI, rendering, fault-tolerant work
Committed use discounts (CUDs)Commit to 1 or 3 years for a discountSteady workloads
Sustained use discountsAutomatic discount for long monthly use on some familiesNothing to do
Sole-tenant nodesPhysical server only for youLicense rules, compliance, isolation
bash gcloud compute instances create batch-worker --zone=asia-south1-a --machine-type=e2-standard-4 \ --provisioning-model=SPOT --instance-termination-action=STOP

Access and Management

  • OS Login: SSH access controlled by IAM roles (roles/compute.osLogin)
  • IAP TCP forwarding: SSH to VMs with no public IP
  • Live migration: Google moves running VMs during maintenance, so most VMs do not reboot
  • Snapshots and machine images back up VMs
  • Instance schedules start and stop VMs automatically to save cost

Choosing Compute Engine

Choose it whenThink about another option when
Need full OS control, special software or lift-and-shiftA container or function can do the job (GKE, Cloud Run)
Licensed software or custom kernelYou do not want to patch servers (use managed services)

Practice

  1. Create a VM with the nginx startup script and open it in a browser
  2. Create a custom machine type with 3 vCPU and 10 GB memory
  3. Create a Spot VM and stop it
  4. SSH using IAP with no external IP
  5. Delete everything you created

Conclusion

Compute Engine provides VMs in many machine families. Choose the smallest type that fits, automate setup with startup scripts, use Spot or committed use discounts to save, and use OS Login with IAP for safe access.

Quick Summary: what; families; images; startup; pricing; access; choosing.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators