How to choose the right machine type and boot image for Google Compute Engine VMs.

Note: Machine family examples below are current as of May 2026. Google Cloud adds new series often, so check the official machine type reference before standardizing on a production shape.


Machine Type Naming Convention

Machine type names follow a pattern:

n2-standard-4
│  │       │
│  │       └─ vCPU count (4 vCPUs)
│  └───────── Subfamily (standard = balanced CPU/memory)
└──────────── Family (n2 = 2nd gen general-purpose)
e2-micro
│     │
│     └─ Shared-core tier (micro, small, medium)
└──────── E2 family (cost-optimized)
PartMeaningExamples
FamilyGeneration and optimization targete2, n2, n4, c4, m4, a4
SubfamilyCPU-to-memory ratio within the familystandard, highcpu, highmem, mega
vCPU countNumber of virtual CPUs2, 4, 8, 16, 32, …
Shared-coreE2 shared-core tiers (fractional vCPU)micro, small, medium

Machine Families

FamilyCurrent Series ExamplesOptimized ForUse Cases
General-purposeE2, N1, N2, N2D, N4, N4D, N4A (Preview), C3, C3D, C4, C4A, C4DBalanced price/performance, with newer C-series options for higher performanceWeb servers, apps, small databases, dev/test, most production services
Compute-optimizedC2, C2D, H3, H4DHigh CPU throughput and HPC-style workloadsBatch processing, gaming, HPC, encoding, tightly coupled compute
Memory-optimizedM1, M2, M3, M4, X4Large memory per VMSAP HANA, in-memory databases, analytics, very large databases
Accelerator-optimizedA2, A3, A4, A4X, G2, G4GPU workloadsML training/inference, rendering, video processing
Storage-optimizedZ3High local SSD throughput and IOPSDatabases, analytics, local scratch-heavy workloads

Note: Machine series availability changes by region and zone. Always confirm that the exact series, GPU, CPU platform, or local SSD option exists in the target zone before designing around it.


General-Purpose Family (Most Common)

SeriesHighlightsDiscount NotesBest For
E2Cost-optimized. Includes shared-core tiers (e2-micro, e2-small, e2-medium).No sustained-use discounts; low on-demand pricing and eligible CUD options are the main savings path.Learning, dev/test, small apps, free tier
N4 / N4D / N4ANewer general-purpose series with improved price/performance. N4 is Intel, N4D is AMD, and N4A is Arm-based but currently Preview.Check current pricing and region availability; newer series may not have the same discount model as N1/N2.New production workloads where GA; evaluation workloads for Preview series
N2 / N2DMature general-purpose Intel/AMD options with broad availability and high max vCPU counts.Eligible for sustained-use discounts and committed-use discounts.Production web apps, databases, general compute
C3 / C3D / C4 / C4A / C4DHigher-performance general-purpose options with newer CPU platforms and stronger networking/storage options.Verify exact series pricing, discount support, and zone availability.Performance-sensitive services, databases, network-heavy apps
N1Older generation with broad legacy compatibility.Eligible for sustained-use discounts, but usually not the first choice for new general-purpose workloads.Legacy workloads or compatibility-driven choices

Rule of thumb: Start with E2 for learning and small workloads. For production, check whether N4/N4D is available in your zone; otherwise N2/N2D remains a safe baseline. Treat Preview series such as N4A as evaluation-only unless your organization accepts Pre-GA constraints. Use C3/C4 families when performance matters more than lowest cost.


Spot VMs and Preemptible VMs

For workloads that can tolerate interruption, GCE offers short-lived VMs at steep discounts:

AspectSpot VMsPreemptible VMs
DiscountUp to 91% off on-demandUp to 91% off on-demand
Max runtimeNo fixed limit (runs until reclaimed)24 hours max
Termination30-second warning via metadata30-second warning via metadata
SLANo SLANo SLA
AvailabilityBest-effort, depends on spare capacityBest-effort
RecommendationPreferred for new workloadsLegacy option, use Spot instead

Good candidates for Spot VMs: Batch jobs, CI/CD builds, ML training (with checkpointing), data processing, rendering.

Bad candidates for Spot VMs: Databases, web servers serving live traffic, any workload that can’t recover from sudden termination.


Custom Machine Types

If no predefined machine type fits your workload, you can create a custom machine type with exact vCPU and memory values:

gcloud compute instances create my-vm \
  --machine-type=custom-6-24576 \
  --zone=us-central1-a

The N1 format is custom-{vCPUs}-{memory-in-MB}. So custom-6-24576 = 6 vCPUs, 24 GB RAM.

  • Newer supported series use series-specific names such as n2-custom-4-16384, n2d-custom-4-16384, or e2-custom-4-16384
  • Supported vCPU and memory ranges depend on the series
  • Custom machine types usually cost more than comparable predefined shapes, but they can still be cheaper when they avoid overprovisioning
  • Available only on supported general-purpose series; check current series docs before standardizing on custom shapes

Custom machine types are worth it when your workload has specific memory requirements that don’t match any predefined type. For most cases, a predefined type is simpler and cheaper.


Choosing the Right Machine Type

Google Compute Engine machine family decision flow

ScenarioRecommended FamilyExample Type
Learning / free tierE2 family / e2-microe2-micro
Small web serverE2e2-medium
New production web appN4 or N2n4-standard-4 or n2-standard-4
Cost-sensitive productionN2Dn2d-standard-4
High-performance computingH3/H4D or C-seriesh3-standard-88 or a current C-series option
In-memory database (Redis, Memcached)M3m3-highmem-8
SAP HANAM3m3-megamem-64 (certified sizes)
ML training (GPU)A3/A4 familyExample depends on GPU generation and regional availability
ML inference (GPU)G2/G4 familyExample depends on GPU generation and regional availability
Batch processing (interruptible)Spot VM on E2/N2Any, with --provisioning-model=SPOT

Images

An image is a boot disk template. When you create a VM, you pick an image that determines the operating system and initial software on the boot disk.

Public Images

OSCommon Image FamiliesCost Notes
Debiandebian-12, earlier supported Debian familiesFree
Ubuntu22.04 LTS, 24.04 LTS, Pro variantsUbuntu LTS is free; Pro images can add licensing cost
Rocky Linux8, 9Free
CentOS Stream9Free; avoid old CentOS Stream 8 for new workloads
Red Hat Enterprise LinuxCurrent supported RHEL familiesPremium unless using an approved bring-your-own-subscription flow
SUSESLES familiesPremium
Windows ServerCurrent supported Windows Server familiesPremium licensing is included in VM cost
Fedora CoreOSStableFree
FreeBSDCurrent supported FreeBSD familiesFree

Tip: For most Linux VMs, Debian 12 or Ubuntu 24.04 LTS are safe defaults. Both are widely supported. Use the image-family flag to get the latest patched image in that family.

Custom Images vs Image Families

ConceptDescription
Public imageProvided by Google or OS vendor. Use for fresh VMs.
Image familyA pointer to the latest image in a series (e.g., debian-12 always points to the latest Debian 12 patch).
Custom imageYou create it from a VM’s boot disk. Use for golden images with pre-installed software.
Machine imageCaptures the full VM configuration (disks, network, metadata). More complete than a custom image.

Snapshots vs Images

AspectSnapshotImage
PurposePoint-in-time backup of a diskBoot disk template for new VMs
Can create VM from it?Yes, by creating a disk from the snapshot firstYes, directly
IncrementalYes (only changed blocks stored)No (full copy)
Use caseBackup and disaster recoveryStandardized VM creation
Cross-regionYes (can share across regions)Yes (can share across regions)

Shielded VMs

Shielded VMs provide verifiable integrity of your VM’s boot stack:

FeatureWhat It Does
Secure BootOnly boots with signed boot loaders and kernels. Prevents rootkits and boot-level malware.
vTPMVirtual Trusted Platform Module. Measures boot integrity and stores measurements for verification.
Measured BootEach boot stage is measured and recorded. You can verify the VM booted with expected software.
Integrity monitoringCloud Monitoring reports when a VM’s boot measurements change from the baseline.

Most public images support Shielded VMs. You can enable it during VM creation:

gcloud compute instances create my-secure-vm \
  --shielded-secure-boot \
  --shielded-vtpm \
  --shielded-integrity-monitoring

Note: Shielded VMs are available on most machine types. Confidential VMs (which encrypt data in use) are available on specific machine types with AMD SEV or Intel TDX.


TL;DR

  • Machine type naming: {family}-{subfamily}-{vcpus} (e.g., n2-standard-4). E2 has shared-core tiers (micro, small, medium).
  • Start with E2 for dev/test. For production, evaluate N4/N4D where available, then N2/N2D as a mature baseline. Use C/H-series for performance-heavy, M/X-series for memory-heavy, and A/G-series for GPU workloads.
  • Spot VMs give up to 91% discount for interruptible workloads. Preferred over legacy preemptible VMs.
  • Custom machine types let you specify exact vCPU/memory on supported general-purpose series. They can cost more per unit, but can still reduce total cost by avoiding overprovisioning.
  • Images are boot disk templates. Use image-family (e.g., debian-12) to get the latest patched image. Debian and Ubuntu LTS images are common free defaults.
  • Shielded VMs add Secure Boot, vTPM, and integrity monitoring for boot-level security.

Resources

Machine Types Reference Complete list of all machine types with vCPU, memory, and pricing details.

General-Purpose Machines Current N, C, E, Tau, and Arm-based general-purpose series.

Compute-Optimized Machines Current H and C2 compute-optimized series.

Accelerator-Optimized Machines Current A and G GPU-backed series.

Public Images Reference All available public images, versions, and image families.

Shielded VM Documentation Details on Secure Boot, vTPM, and integrity monitoring.

Google Compute Engine Overview of GCE features and architecture.

Creating Your First VM Step-by-step guide to launching a VM on GCP.