Compute Engine Machine Types
Understand GCP machine families (E2, N2, C2, M2) and choose the right type for your workload.
Prerequisites
- GCP project with Compute Engine access
- Understanding of CPU, RAM, and workload profiling
Compute Engine Machine Families Overview
Google Compute Engine offers a wide range of virtual machine types organized into machine families. Each family is optimized for different workload profiles. Choosing the right machine type has a direct impact on both performance and cost. An over-provisioned VM wastes money, while an under-provisioned one creates bottlenecks that degrade user experience and slow down batch processing.
GCP organizes machine types into four main categories: General Purpose, Compute Optimized, Memory Optimized, and Accelerator Optimized. Within each category are specific machine series identified by generation letters and numbers (e.g., E2, N2, C3). Newer generations generally offer better performance-per-dollar, but availability varies by region.
The naming convention follows a pattern: [series]-[type]-[vcpus]. For example, n2-standard-8 means the N2 series, standard memory ratio, with 8 vCPUs. The memory ratio types are: standard (1:4 GB), highmem (1:8 GB), highcpu (1:1 GB), and variations like megamem and ultramem for memory-optimized families.
General Purpose Machines
General-purpose machines offer a balanced ratio of compute, memory, and networking. They are the right starting point for most workloads and should be your default choice unless you have identified a specific resource bottleneck that warrants a specialized family.
| Series | Processor | vCPU : Memory Ratio | Max vCPUs | Best For |
|---|---|---|---|---|
| E2 | Intel / AMD (shared core available) | 1:4 GB (standard) | 32 | Dev/test, small workloads, cost-sensitive |
| N2 | Intel Cascade Lake / Ice Lake | 1:4 GB (standard) | 128 | General production, databases, web servers |
| N2D | AMD EPYC Rome / Milan | 1:4 GB (standard) | 224 | Same as N2, often 10-20% cheaper |
| C3 | Intel Sapphire Rapids | 1:4 GB (standard) | 176 | Latest gen, best per-core performance |
| C3D | AMD EPYC Genoa | 1:4 GB (standard) | 360 | Highest vCPU count, large-scale workloads |
| T2D | AMD EPYC Milan | 1:4 GB (fixed) | 60 | Scale-out workloads, containerized apps |
E2 Series: Cost-Optimized Development
The E2 series is GCP's most cost-effective general-purpose offering. It uses a shared-core architecture for smaller instances (e2-micro, e2-small, e2-medium) where the vCPU is a fraction of a physical core. E2 instances use CPU bursting, which means they can temporarily use more CPU than their baseline when the host has spare capacity, but sustained performance is not guaranteed.
E2 instances are ideal for development, testing, and low-traffic applications. They are not recommended for production workloads that require consistent performance because the burst model can lead to unpredictable latency under sustained load.
N2 / N2D Series: Production Workhorse
The N2 (Intel) and N2D (AMD) series are the workhorses of production GCP deployments. They provide dedicated cores with consistent performance, support custom machine types, and are eligible for Sustained Use Discounts (up to 30% automatic discount for running more than 25% of the month). The N2D series typically costs 10-20% less than N2 for equivalent performance, making it a strong default choice.
C3 / C3D Series: Latest Generation
The C3 (Intel Sapphire Rapids) and C3D (AMD EPYC Genoa) represent GCP's newest general-purpose offerings. They provide significantly better per-core performance than N2 and support up to 176 vCPUs (C3) or 360 vCPUs (C3D). However, they do not receive Sustained Use Discounts; instead, use Committed Use Discounts for cost savings with these series.
Start with E2, Graduate to N2/C3
For development and testing, E2 instances offer the lowest cost with shared-core options as small as e2-micro (0.25 vCPU, 1 GB RAM) which is also included in the GCP free tier. When promoting to production, move to N2D (for cost efficiency) or C3 (for best performance). The E2 series uses CPU bursting, which means performance can be unpredictable under sustained load.
Compute Optimized Machines
Compute-optimized machines provide the highest per-core performance for workloads that are CPU-bound. They run at higher clock speeds and are tuned for sustained compute-intensive operations.
C2 Series
The C2 series uses Intel Cascade Lake processors running at 3.8 GHz sustained all-core turbo frequency. This is the highest sustained frequency available on GCP and is ideal for single-threaded performance-sensitive workloads.
C2D Series
The C2D series uses AMD EPYC Milan processors and offers up to 112 vCPUs per VM. It provides a good balance between per-core performance and core count for workloads that benefit from both.
H3 Series
The H3 series is purpose-built for HPC (High Performance Computing) workloads. Each VM has 88 vCPUs and 352 GB of memory on Intel Sapphire Rapids processors. H3 VMs are deployed on dense nodes with 200 Gbps networking for MPI and tightly-coupled parallel workloads.
| Series | Processor | Max vCPUs | Best For |
|---|---|---|---|
| C2 | Intel Cascade Lake (3.8 GHz) | 60 | Single-threaded apps, game servers |
| C2D | AMD EPYC Milan | 112 | Batch processing, media transcoding |
| H3 | Intel Sapphire Rapids | 88 (fixed) | HPC, simulations, MPI workloads |
Ideal use cases for compute-optimized machines:
- Scientific computing and simulations
- Game servers requiring single-threaded performance
- High-performance batch processing
- Media transcoding pipelines
- Computational fluid dynamics (CFD)
- Financial modeling and risk analysis
# C2 for single-threaded performance
gcloud compute instances create game-server-01 \
--machine-type=c2-standard-8 \
--zone=us-central1-a \
--image-family=ubuntu-2404-lts \
--image-project=ubuntu-os-cloud \
--network-interface=no-address \
--service-account=game-server@my-project.iam.gserviceaccount.com \
--shielded-secure-boot \
--shielded-vtpm
# C2D for high-core-count batch processing
gcloud compute instances create batch-processor \
--machine-type=c2d-standard-56 \
--zone=us-central1-a \
--image-family=ubuntu-2404-lts \
--image-project=ubuntu-os-cloud \
--boot-disk-size=200GB \
--boot-disk-type=pd-ssd \
--local-ssd=count=4,interface=NVMEMemory Optimized Machines
Memory-optimized machines offer the highest memory-to-vCPU ratios, designed for workloads that need to keep large datasets in memory. These machines are significantly more expensive per vCPU than general-purpose instances, so they should only be used when the workload genuinely requires high memory capacity.
| Series | Processor | Max Memory | Memory/vCPU | Best For |
|---|---|---|---|---|
| M1 | Intel Skylake | 3,844 GB | Up to 24 GB/vCPU | Legacy SAP HANA, large in-memory workloads |
| M2 | Intel Cascade Lake | 11,776 GB | Up to 28 GB/vCPU | Largest SAP HANA deployments |
| M3 | Intel Ice Lake | 3,904 GB | Up to 30.5 GB/vCPU | SAP HANA, in-memory analytics |
Ideal use cases for memory-optimized machines:
- SAP HANA in-memory databases
- Large-scale in-memory caching (when Memorystore is not sufficient)
- Real-time analytics with large datasets
- Genomics and bioinformatics workloads
- Apache Spark with large in-memory datasets
Consider Managed Alternatives First
Before provisioning memory-optimized VMs, consider whether a managed service could handle your workload. Memorystore for Redis supports up to 300 GB of in-memory data with automatic HA. BigQuery handles analytical queries over petabytes without requiring in-memory processing. Managed services eliminate operational overhead and often provide better price-performance for standard workloads.
Accelerator Optimized Machines
These machines come with attached NVIDIA GPUs for machine learning training, inference, and graphics rendering. GPU availability varies significantly by region, so check availability before committing to a specific GPU type. GPU-attached VMs have specific machine type requirements and cannot use custom machine types.
| Series | GPU | GPUs per VM | GPU Memory | Use Case |
|---|---|---|---|---|
| A2 | NVIDIA A100 | 1 to 16 | 40 or 80 GB per GPU | ML training, HPC |
| A3 | NVIDIA H100 | 8 | 80 GB per GPU | Large-scale ML training, LLM fine-tuning |
| G2 | NVIDIA L4 | 1 to 8 | 24 GB per GPU | ML inference, video transcoding, rendering |
Choosing the Right GPU
The choice between GPU types depends on your workload:
- Training large models (LLMs, diffusion models): A3 with H100 GPUs. The H100 provides 3x the training performance of the A100 for transformer-based models thanks to the Transformer Engine and FP8 support.
- Training medium models or fine-tuning: A2 with A100 GPUs. Good balance of performance and cost. Available in more regions than A3.
- Inference and real-time serving: G2 with L4 GPUs. Lower cost per GPU, optimized for inference with INT8 and FP8 acceleration. Also available on Cloud Run for serverless GPU inference.
- Video transcoding and rendering: G2 with L4 GPUs. The L4 includes hardware video encoding/decoding engines.
# A2 VM with 1 A100 GPU for ML training
gcloud compute instances create ml-training-01 \
--machine-type=a2-highgpu-1g \
--zone=us-central1-a \
--image-family=common-cu123-debian-11 \
--image-project=deeplearning-platform-release \
--boot-disk-size=200GB \
--boot-disk-type=pd-ssd \
--maintenance-policy=TERMINATE \
--restart-on-failure
# G2 VM with 1 L4 GPU for inference
gcloud compute instances create inference-server \
--machine-type=g2-standard-4 \
--zone=us-central1-a \
--image-family=common-cu123-debian-11 \
--image-project=deeplearning-platform-release \
--boot-disk-size=100GB \
--provisioning-model=SPOT \
--instance-termination-action=STOPGPU Quota and Availability
GPU quota is limited and must be requested separately from CPU quota. Request GPU quota well in advance of needing it, as approvals can take days. Check GPU availability per zone using gcloud compute accelerator-types list before selecting your deployment region. For production ML workloads, consider using Vertex AI, which manages GPU allocation automatically and provides autoscaling.
Custom Machine Types
If predefined machine types do not match your workload, GCP allows you to create custom machine types with any combination of vCPUs and memory (within supported ratios). This can save 20-40% compared to using the next larger predefined type. Custom machine types are available for the E2, N1, N2, and N2D series.
Custom Machine Type Rules
- vCPUs must be in multiples of 2 (or 1 for shared-core E2)
- Memory must be in multiples of 256 MB
- Standard memory range: 1-8 GB per vCPU
- Extended memory (above 8 GB/vCPU) available for N1, N2, N2D at additional cost
- The E2 series does not support extended memory
# Custom machine type: 6 vCPUs, 24 GB memory (N2 series)
gcloud compute instances create my-instance \
--machine-type=n2-custom-6-24576 \
--zone=us-central1-a \
--image-family=ubuntu-2404-lts \
--image-project=ubuntu-os-cloud
# Custom machine type with extended memory (above 8 GB/vCPU)
# Requires the "ext" suffix and costs more per GB
gcloud compute instances create high-mem-instance \
--machine-type=n2-custom-4-32768-ext \
--zone=us-central1-a \
--image-family=ubuntu-2404-lts \
--image-project=ubuntu-os-cloud
# List available machine types in a zone
gcloud compute machine-types list \
--zones=us-central1-a \
--filter="name:n2-standard" \
--format="table(name, guestCpus, memoryMb, description)"| Machine Type | vCPUs | Memory (GB) | On-Demand Price (approx) | Savings vs Next Predefined |
|---|---|---|---|---|
| n2-standard-8 | 8 | 32 | $0.388/hr | Baseline |
| n2-custom-6-24576 | 6 | 24 | $0.291/hr | 25% vs n2-standard-8 |
| n2-standard-4 | 4 | 16 | $0.194/hr | Baseline (smaller) |
| n2-custom-4-20480 | 4 | 20 | $0.210/hr | 46% vs n2-standard-8 (right-sized) |
Use Custom Types for Right-Sizing
When the Recommender suggests a machine type change but the recommended predefined type still does not match your workload profile (e.g., you need 6 vCPUs but predefined types jump from 4 to 8), create a custom machine type that exactly matches your needs. This eliminates both over-provisioning and under-provisioning.
Sole-Tenant Nodes
Sole-tenant nodes provide dedicated physical servers for your VMs. Your VMs run on hardware that is not shared with any other customer. This is required for certain compliance requirements (HIPAA, PCI-DSS) and for bring-your-own-license (BYOL) scenarios where software licenses are tied to physical cores.
- Compliance: Some regulatory frameworks require physical isolation of compute resources.
- BYOL licensing: Software like Windows Server, SQL Server, or Oracle can be licensed per physical core. Sole-tenant nodes let you count only your cores, not shared infrastructure.
- Anti-affinity: Ensure VMs are placed on different physical nodes for HA within a zone.
# Create a node template
gcloud compute sole-tenancy node-templates create my-template \
--node-type=n2-node-80-640 \
--region=us-central1
# Create a node group
gcloud compute sole-tenancy node-groups create my-node-group \
--node-template=my-template \
--target-size=2 \
--zone=us-central1-a \
--maintenance-policy=MIGRATE_WITHIN_NODE_GROUP
# Deploy a VM to the sole-tenant node group
gcloud compute instances create my-vm \
--machine-type=n2-standard-16 \
--zone=us-central1-a \
--node-group=my-node-group \
--image-family=windows-2022 \
--image-project=windows-cloudPricing and Discount Programs
Compute Engine pricing is per-second with a 1-minute minimum. There are several discount mechanisms that can dramatically reduce costs. Some stack with each other, while others are mutually exclusive.
| Discount Type | Savings | Requirements | Applicable Series |
|---|---|---|---|
| Sustained Use Discount | Up to 30% | Run VM >25% of month (automatic) | N1, N2, N2D only |
| Committed Use Discount (1yr) | 37% | 1-year commitment for vCPU and memory | All series |
| Committed Use Discount (3yr) | 57% | 3-year commitment for vCPU and memory | All series |
| Spot VMs | 60-91% | Workload tolerates preemption | All series |
Sustained Use Discounts
Sustained Use Discounts are automatically applied to N1, N2, and N2D instances that run for more than 25% of a month. The discount increases incrementally: 0% for the first 25%, then progressively increasing up to 30% for usage exceeding 75% of the month. No commitment or configuration is required: it just happens.
Committed Use Discounts
CUDs provide 37% (1-year) or 57% (3-year) discounts in exchange for committing to a specific amount of vCPU and memory resources in a region. Unlike AWS Reserved Instances, GCP CUDs are flexible:
- They apply to any machine type within the same region
- You can change between machine series (N2, C3, etc.) without losing the discount
- CUDs cover vCPU and memory amounts, not specific instance counts
- They apply automatically to running VMs; no manual matching needed
# Purchase a 1-year CUD for 100 vCPUs and 400 GB memory in us-central1
gcloud compute commitments create my-commitment \
--region=us-central1 \
--resources=vcpu=100,memory=409600MB \
--plan=twelve-month \
--type=GENERAL_PURPOSE
# List active commitments
gcloud compute commitments list \
--region=us-central1 \
--format="table(name, plan, status, resources)"
# Check CUD utilization
gcloud recommender recommendations list \
--recommender=google.compute.commitment.UsageCommitmentRecommender \
--project=my-project \
--location=us-central1Spot VMs
Spot VMs offer 60-91% discounts for workloads that can tolerate interruption. GCP can reclaim Spot VMs with 30 seconds notice when it needs the capacity. Spot VMs are ideal for batch processing, distributed computing, CI/CD, and any workload that can checkpoint and resume.
# Single Spot VM
gcloud compute instances create batch-worker-01 \
--machine-type=c2-standard-16 \
--zone=us-central1-a \
--provisioning-model=SPOT \
--instance-termination-action=STOP \
--maintenance-policy=TERMINATE \
--image-family=ubuntu-2404-lts \
--image-project=ubuntu-os-cloud
# Managed Instance Group with Spot VMs (auto-scaling batch)
gcloud compute instance-templates create spot-batch-template \
--machine-type=c2d-standard-16 \
--provisioning-model=SPOT \
--instance-termination-action=DELETE \
--image-family=ubuntu-2404-lts \
--image-project=ubuntu-os-cloud \
--metadata=startup-script='#!/bin/bash
docker pull gcr.io/my-project/batch-worker:latest
docker run --rm gcr.io/my-project/batch-worker:latest'
gcloud compute instance-groups managed create batch-workers \
--template=spot-batch-template \
--size=0 \
--zone=us-central1-a
# Scale up when needed
gcloud compute instance-groups managed resize batch-workers \
--size=20 \
--zone=us-central1-aSpot VM Best Practices
Always implement graceful shutdown handlers for Spot VMs. GCP sends a preemption notice 30 seconds before terminating the VM, which you can detect via the metadata server. Use --instance-termination-action=STOP if you want the VM to stop (preserving disk) rather than delete. For batch processing, checkpoint progress frequently so work is not lost on preemption. Never use Spot VMs for stateful services or databases.
Right-Sizing Recommendations
GCP automatically monitors VM utilization and provides right-sizing recommendations through the Recommender API and the Cloud Console. After a VM has been running for at least 8 days, you will see suggestions to resize if the VM is consistently underutilized. These recommendations consider CPU, memory, and network utilization patterns.
# List all VM right-sizing recommendations for a project
gcloud recommender recommendations list \
--recommender=google.compute.instance.MachineTypeRecommender \
--project=my-project \
--location=us-central1-a \
--format="table(name, content.operationGroups[0].operations[0].value.machineType, stateInfo.state)"
# List idle VM recommendations (VMs that should be stopped or deleted)
gcloud recommender recommendations list \
--recommender=google.compute.instance.IdleResourceRecommender \
--project=my-project \
--location=us-central1-a
# Get detailed recommendation with cost impact
gcloud recommender recommendations describe RECOMMENDATION_ID \
--recommender=google.compute.instance.MachineTypeRecommender \
--project=my-project \
--location=us-central1-a
# Export recommendations to BigQuery for fleet-wide analysis
gcloud asset export \
--content-type=recommendation \
--project=my-project \
--output-bigquery-force \
--output-bigquery-dataset=my_dataset \
--output-bigquery-table=recommendationsDo Not Blindly Follow Recommendations
Right-sizing recommendations are based on observed peak utilization. If your workload has seasonal spikes (end-of-quarter processing, Black Friday traffic), the recommendation period may not capture peak usage. Always check at least 30 days of utilization data before downsizing, and consider using autoscaling Managed Instance Groups instead of fixed-size VMs for variable workloads.
Machine Type Selection Decision Framework
Use this framework to select the right machine type for your workload:
| Workload Characteristic | Recommended Series | Why |
|---|---|---|
| Dev/test, low traffic | E2 (shared-core) | Lowest cost, free tier eligible |
| General production | N2D or C3D | Best price-performance for most workloads |
| Latency-sensitive single-threaded | C2 | Highest per-core clock speed |
| Scale-out containers | T2D or E2 | Optimized for horizontal scaling |
| In-memory databases | M3 | Highest memory-to-CPU ratio |
| ML training | A2 or A3 (with GPUs) | Purpose-built for GPU workloads |
| ML inference | G2 (or Cloud Run with GPU) | Cost-effective L4 GPUs |
| HPC / simulations | H3 or C2D | High core count, fast interconnect |
Consider Serverless First
Before choosing a machine type, ask whether you need a VM at all. Cloud Run, Cloud Functions, and GKE Autopilot abstract away machine selection entirely and often provide better cost efficiency for variable workloads. Use Compute Engine VMs when you need persistent local storage, specific hardware (GPUs, local SSDs), or workloads that do not fit the serverless model.
Key Takeaways
- 1E2 is the most cost-effective for general workloads. Use it as the default starting point.
- 2N2/N2D offer higher per-core performance for production workloads needing consistent speed.
- 3C2/C2D are compute-optimized for HPC, gaming, and CPU-intensive batch processing.
- 4M2/M3 are memory-optimized for SAP HANA, large databases, and in-memory analytics.
- 5Custom machine types let you specify exact vCPU and memory for cost optimization.
- 6Spot VMs offer up to 91% discount for fault-tolerant, interruptible workloads.
Frequently Asked Questions
What is the difference between E2 and N2 machine types?
What are custom machine types?
When should I use Spot VMs?
How do I choose the right machine family?
What is the difference between Sole-tenant nodes and regular VMs?
Written by CloudToolStack Team
Cloud engineers and architects with hands-on experience across AWS, Azure, and GCP. We write guides based on real-world production patterns, not just documentation rewrites.
Disclaimer: This guide is for educational purposes. Cloud services change frequently; always refer to official documentation for the latest information. AWS, Azure, and GCP are trademarks of their respective owners.