Google Cloud · Compute
Compute Engine
Virtual machines on Google's infrastructure, from small shared-core VMs to GPU and memory-optimised machines, billed per second.
On the Google Cloud Associate Cloud Engineer exam listAutomation
What it is and what problem it solves
Compute Engine runs virtual machines in a zone you choose. You pick a machine type from a family (general-purpose E2, N2, N4 or C4; compute-, memory- or accelerator-optimised), a boot image, disks, a network interface in a VPC subnet and an attached service account that gives software on the VM short-lived credentials. Managed instance groups create identical VMs from an instance template and add autoscaling, autohealing and rolling updates; regional groups spread VMs across zones.
When to use it
- Software that needs a full operating system: legacy or packaged applications, specific kernels or drivers.
- Lift-and-shift migrations before modernising.
- Steady, heavy workloads where committed use discounts make VMs cheapest.
- GPU or TPU workloads that need direct control of the machine.
- Batch and fault-tolerant work on cheap Spot VMs.
When to avoid it
- Stateless HTTP services and event handlers: Cloud Run removes the servers to patch and scales to zero.
- Many containerised services sharing a platform: GKE.
- Single VMs for production without a managed instance group: nothing replaces them when they fail.
Scaling model and bottlenecks
Scale out with a managed instance group autoscaler on CPU, load balancer utilisation, schedules or custom metrics; scale up by changing the machine type (requires a stop). Regional managed instance groups keep VMs in several zones so a zone failure leaves capacity running.
Limits and quotas
| Item | Value | Context | Source |
|---|---|---|---|
| Spot VM discount | 60-91% | Compared with on-demand prices; Spot VMs can be preempted at any time. | Source checked |
Quotas and limits change. Check the linked source before designing around a number.
Cost model
What you pay for
- vCPU and memory per second (one-minute minimum), by machine type and region.
- Disks (Persistent Disk or Hyperdisk) and snapshots, billed separately and even while the VM is stopped.
- GPUs, licences (Windows, some OS images) and external IP addresses.
- Network egress to the internet or other regions.
Where it is cost-efficient
Right-sized VMs running most of the month with sustained use or committed use discounts; Spot VMs for interruptible work.
Where costs grow
Oversized machine types, VMs left running in non-production, unattached disks and old snapshots, idle static IPs.
Cost controls and common surprises
Use rightsizing recommendations, schedules to stop non-production VMs, committed use discounts for the steady base and Spot VMs for batch.
Prices differ by Region and change over time; see the pricing page linked under Sources.
Security
Controls the service provides
- Shielded VMs (secure boot, measured boot, integrity monitoring) and Confidential VMs for memory encryption.
- OS Login ties SSH access to IAM identities instead of copied keys.
- Disks are encrypted at rest by default, with optional customer-managed keys (CMEK).
What you configure
Run VMs without external IP addresses (reach them through IAP TCP forwarding), attach a dedicated service account with minimal roles (not the default compute service account), patch the OS (VM Manager), and restrict traffic with firewall policies targeting service accounts or secure tags.
Logging and monitoring
Admin Activity audit logs record VM changes; the Ops Agent sends OS logs and metrics to Cloud Logging and Monitoring.
Shared responsibility
Google secures the hardware and hypervisor; you secure the guest OS, software, identities and network rules.
Availability, backup and failure behavior
A VM lives in one zone. Use regional managed instance groups behind a load balancer, autohealing health checks and regional Persistent Disk for stateful VMs that must survive a zone failure. Live migration moves VMs during Google's host maintenance without a reboot.
Exam cues and common confusions
- Autoscaling and self-healing VMs: a managed instance group from an instance template, with a health check.
- Cheapest for fault-tolerant batch: Spot VMs; steady load: committed use discounts.
- SSH without managing keys: OS Login; no public IP: IAP TCP forwarding.
- Custom machine types when no predefined shape fits.
Related
Courses and lessons
- The Load Balancer That Returned 502 · Google Cloud in Production · Members
Services, comparisons and patterns
- Persistent Disk and Hyperdisk · Service
- Cloud Load Balancing · Service
- Virtual Private Cloud (VPC) · Service
- Google Kubernetes Engine (GKE) · Service
- Cloud Run vs GKE vs Compute Engine · Comparison
- High availability · Concept
Sources
Independent study material, not affiliated with or endorsed by Google. Google Cloud and service names are trademarks of Google LLC.