DevOps Peach

GCP Basics · Compute Engine – Machine Types, VMs, Disks and Managed Instance Groups · Lesson 5 of 5

VM Availability: Zones, Live Migration and Regional Disks

Compute Engine live-migrates most VMs during host maintenance; design for zone failure with regional MIGs and regional disks, and set maintenance and restart policies per VM.

Practice interactively →

Google maintains hosts constantly. Most VMs never notice because of live migration. Zone and region failures are your design problem.

flowchart LR
  H["Host maintenance event"] --> LM["Live migration<br/>VM keeps running"]
  Z["Zone asia-southeast1-a fails"] --> MIG["Regional MIG recreates VMs<br/>in zones b and c"]
  Z --> RPD["Regional disk data-r<br/>replica in zone b"]
  RPD --> FO["Force-attach to standby VM"]
  R["Region outage"] --> DR["Restore from snapshots<br/>in asia-southeast2"]
  %% step H: When Google updates host hardware or software, it schedules a maintenance event.
  %% step LM: Live migration moves the running VM to another host with only a short pause; set onHostMaintenance to MIGRATE.
  %% step Z: A whole zone can fail; nothing inside one zone protects against that.
  %% step MIG: A regional MIG brings capacity back in the remaining zones automatically.
  %% step RPD: A regional Persistent Disk keeps a synchronous copy in a second zone.
  %% step FO: For a stateful VM, attach the regional disk to a standby VM in the healthy zone.
  %% step DR: For a region outage, restore from multi-regional snapshots or images in another region.

Host maintenance settings

Setting Values Notes
onHostMaintenance MIGRATE (default) or TERMINATE Some GPU VMs and Spot VMs must terminate
automaticRestart true (default) Restart after a host crash or termination

gcloud compute instances set-scheduling web-1 --maintenance-policy=MIGRATE --restart-on-failure --zone=…

You can see upcoming maintenance in the metadata server (maintenance-event) and simulate it with gcloud compute instances simulate-maintenance-event.

Availability levels

Design Protects against
Single VM with live migration and auto restart Host maintenance and host failure
VMs in two or more zones (regional MIG) behind a load balancer Zone failure (higher Compute Engine SLA for multi-zone deployments)
Regional disks for state Zone failure with no data loss (RPO ≈ 0)
Second region + snapshots/replication + global LB Region failure

Placement and capacity

Backups

Combine snapshot schedules (module lesson 3), machine images before risky changes, and the Backup and DR service for centrally managed backup plans across VMs and databases.

gcloud compute disks create data-r --region=asia-southeast1   --replica-zones=asia-southeast1-a,asia-southeast1-b --size=200GB --type=pd-balanced
gcloud compute instances attach-disk db-standby --disk=data-r --disk-scope=regional   --zone=asia-southeast1-b --force-attach
Command Meaning
gcloud compute instances describe web-1 --format="value(scheduling)" Maintenance settings
gcloud compute reservations create res-web --zone=… --vm-count=3 --machine-type=e2-medium Reserve capacity

Traps: a single VM, however large, is still one zone; regional disks cost about twice a zonal disk; reservations are billed even when unused.

Practice interactively →