Compute Engine Study Notes
Compute Engine is Google Cloud's infrastructure-as-a-service offering that lets you create and run virtual machines on Google's infrastructure. You control the operating system, machine type, disks, and networking. It is the most flexible compute option and the one to choose when you need full control over the VM environment.
Key facts
- Machine families include general-purpose, compute-optimized, memory-optimized, and accelerator-optimized types, so you match CPU, memory, and GPU resources to the workload rather than paying for a one-size configuration.
- Persistent disks are network-attached block storage that live independently of a VM, while local SSDs are physically attached, offer higher IOPS, and lose data when the instance stops.
- Custom images are created from a source disk, instance, or image and let you capture a configured boot disk so new instances start in a known, repeatable state.
- Managed instance groups use an instance template and can autoscale and autoheal across zones, whereas unmanaged instance groups contain heterogeneous VMs that you maintain manually.
- Spot VMs, the successor to preemptible VMs, offer deeply discounted spare capacity but can be preempted with a short termination notice and carry no availability guarantee.
- A VM's internal IP address can change when it is stopped and started unless you reserve a static internal address, while external addresses are ephemeral by default until promoted to static.
- Live migration lets Google move a running VM to another host during infrastructure maintenance without rebooting it, which is a default behavior you do not need to configure.
- Shielded VMs add verified boot, vTPM, and integrity monitoring to help protect against boot-level and firmware-level attacks.
What the exam expects you to know
- Choosing the right machine family and disk type for a workload described by CPU, memory, IOPS, and cost constraints in a scenario question.
- Explaining when to use a managed instance group with autoscaling versus a single VM or an unmanaged group for a set of existing instances.
- Distinguishing persistent disk snapshots, custom images, and machine images, and knowing that a machine image stores the full VM configuration plus multiple disks.
- Recognizing Spot VM behavior, including preemption, no SLA, and why such instances suit fault-tolerant, batch, or stateless jobs only.
- Configuring metadata, startup scripts, and service accounts on an instance, and understanding that startup scripts run every time the instance boots.
- Understanding sole-tenant nodes for licensing or compliance isolation, and committed use discounts for predictable, long-running resource usage.
Compute Engine vs Google Kubernetes Engine: when to use which
Choose Compute Engine when an application needs a specific operating system, kernel tuning, licensed software tied to a machine, or direct control over disks and networking. Choose GKE when the workload is already containerized and you want orchestrated scheduling, rolling updates, and self-healing pods managed for you. The decision often comes down to control versus abstraction: Compute Engine gives you the VM and all responsibility for patching and scaling it, while GKE removes node and container scheduling work but requires your application to fit a container and Kubernetes model. See also the Google Kubernetes Engine notes.
Useful gcloud commands
gcloud compute instances create my-vm --zone=us-central1-a --machine-type=e2-medium
gcloud compute instances list
gcloud compute snapshots create my-snapshot --source-disk=my-disk --zone=us-central1-a
gcloud compute instance-groups managed create my-mig --template=my-template --size=3 --zone=us-central1-aCommon exam traps
- Thinking a stopped VM stops all charges: persistent disks and reserved static external IP addresses continue to incur charges even when the instance itself is not running.
- Assuming local SSD data survives a stop: local SSDs are ephemeral and their contents are lost when the instance stops, unlike persistent disks which retain data.
- Confusing a snapshot with an image: a snapshot is a backup of one persistent disk, while a custom image is a bootable template used to create new boot disks.
- Believing an external IP is permanent by default: ephemeral external addresses can change on stop and start, so promote the address to static when a fixed address is required.
Frequently asked questions
What is the difference between a snapshot and a machine image?
A snapshot backs up the data on a single persistent disk and is mainly for backup and for creating disks in other zones or regions. A machine image captures the entire VM configuration, including instance metadata, permissions, and all attached disks, so you can clone or restore a complete instance in one operation.
When should I use Spot VMs?
Use Spot VMs for workloads that can tolerate interruption, such as batch processing, rendering, CI jobs, and stateless workers behind a load balancer. Google can preempt them when capacity is needed elsewhere, and they carry no SLA, so never place a sole production database or any non-replicated critical service on them.
How does autoscaling work in a managed instance group?
You set a minimum and maximum instance count and a signal such as average CPU utilization, load balancing capacity, or a Cloud Monitoring metric. The autoscaler adds instances when the signal rises above your target and removes them during quiet periods, while health checks and autohealing replace instances that fail.
Study aid disclaimer: Cloud Cert Notes is an independent educational study aid. It is not affiliated with, endorsed by, or sponsored by Google, Microsoft, Amazon, Oracle, or Alibaba. Google Cloud, Associate Cloud Engineer, and Cloud Digital Leader are trademarks of Google LLC; all other certification names and product names are trademarks of their respective owners. Always confirm service details against the official provider documentation before sitting an exam.