GCP Machine Types Explained: How to Choose the Right Compute Engine VM

A machine type defines the CPU and memory allocated to a Compute Engine VM. Picking the wrong one is the most common way to overpay on GCP or get unexpectedly poor performance. This guide explains how machine types work, what the naming format means, and how to choose the right size for your actual workload, not just the one that looks safe.

What is a machine type?

When you create a Compute Engine VM, you are renting compute resources on Google’s infrastructure. A machine type tells GCP exactly what hardware to give you: how many virtual CPUs (vCPUs) and how much RAM. Everything else (the operating system, disk, and network configuration) is a separate choice.

🚗

Analogy

Think of a machine type like choosing a vehicle. The vCPUs are the engine (processing power) and the RAM is the cargo space (how much data the engine can work with at once). A sports car has a powerful engine but tiny boot space. A van has huge cargo capacity but is not built for speed. A family car balances both. Machine types work the same way: highcpu, highmem, or standard, depending on what your workload actually needs.

Most beginners over-provision. They pick a large machine type “just in case” and end up paying for CPU and RAM that sits idle. The better approach is to start conservatively, monitor real usage, and resize when you have evidence.

The three core workload types that guide your initial choice:

  • CPU-heavy: video encoding, scientific computing, game servers. Needs high clock speed or many vCPUs.
  • Memory-heavy: in-memory databases, caching layers, SAP HANA. Needs a high RAM-to-vCPU ratio.
  • Balanced: web servers, APIs, microservices. Standard 4 GB per vCPU ratios work well for most cases.

How machine type names work

Machine type names follow a consistent format that tells you everything upfront:

FAMILY-RATIO-vCPUs

ExampleFamilyRatiovCPUsRAM (approx)
e2-standard-4E2standard (4 GB/vCPU)416 GB
n2-highmem-8N2highmem (8 GB/vCPU)864 GB
n2-highcpu-16N2highcpu (~1 GB/vCPU)16~16 GB
c2-standard-4C2standard416 GB
n2-custom-6-12288N2custom612 GB
The three ratios

standard is roughly 4 GB per vCPU — balanced, suits most workloads.
highmem is roughly 8 GB per vCPU — more RAM relative to CPU, suits databases and caches.
highcpu is roughly 1 GB per vCPU — more CPU relative to RAM, suits batch processing.
custom lets you specify exact values when no preset fits without waste.

Machine type families

General purpose: E2, N2, N2D, N4

Start here for most workloads. General-purpose families offer balanced vCPU-to-memory ratios and cover the majority of web, API, and application backend use cases.

  • E2 is cost-optimised and shares physical CPU cores across tenants. CPU performance can vary under load. Best for dev/test, microservices, and workloads that do not need consistent CPU response times.

  • N2 runs on Intel Cascade Lake with dedicated vCPUs and predictable performance. The default choice for medium-sized production workloads. Supports custom machine types.

  • N2D runs on AMD EPYC with a similar workload fit to N2 but often lower price per vCPU. Worth comparing for cost-sensitive production work where platform preference is not a constraint.

  • N4 uses Intel Emerald Rapids, the latest-generation general-purpose option. Higher per-vCPU performance than N2.

Compute optimised: C2, C2D, C3

High clock-speed CPUs for tasks where raw compute throughput is the bottleneck. Do not use these for general web serving: they cost more and the extra CPU speed provides no benefit to workloads that are mostly idle or waiting on I/O.

  • C2 uses Intel Cascade Lake with the highest sustained clock frequency in GCP’s standard range. Good for scientific computing and game servers.
  • C2D is AMD EPYC-based with a large L3 cache that suits workloads with high data reuse such as simulations and analytics.
  • C3 uses Intel Sapphire Rapids and is the current-generation compute-optimised option. Generally preferred over C2 for new deployments.
Common mistake

C2 and C3 are expensive because of their clock speed. If your application spends most of its time waiting on database queries, disk reads, or network responses, a C2 or C3 will cost more and deliver the same throughput as an E2. High clock speed only helps when the CPU is actually the bottleneck.

Memory optimised: M1, M2, M3

Very high memory-to-vCPU ratios for in-memory databases, SAP HANA instances, and data warehousing workloads that cannot fit within standard memory limits. These are large, expensive VMs. Only reach for them when you genuinely need more RAM than general-purpose highmem types can provide.

  • M1: up to 4 TB of memory per VM.
  • M2: up to 12 TB of memory per VM.
  • M3: latest generation memory-optimised, higher performance than M1 and M2.

Accelerator optimised: A2, A3, G2

GPU-attached VMs for ML training, inference, and high-performance computing. Only use these when your workload explicitly benefits from GPU acceleration.

  • A2: NVIDIA A100 GPUs, an established ML training option.
  • A3: NVIDIA H100 GPUs, current generation for large-scale training.
  • G2: NVIDIA L4 GPUs, suited for inference and media transcoding at lower cost than A100.

E2 vs N2 vs N2D vs C2 vs C3

The general-purpose and compute-optimised families are where most beginners get stuck. Here is a direct comparison:

FamilyBest forStrengthTrade-offGood starter?
E2Dev/test, low-traffic appsLowest costShared CPU; can be throttled under loadYes, for non-critical work
N2Production web and API backendsDedicated vCPUs, consistent performanceCosts more than E2 for the same vCPU countYes, for production
N2DCost-sensitive production workOften cheaper per vCPU than N2AMD platform; some software or licensing prefers IntelYes, worth comparing to N2
C2CPU-bound batch, game serversHigh sustained clock speedPoor value for idle or I/O-bound workloadsOnly if CPU is the measured bottleneck
C3High-throughput compute workloadsNewer architecture, better performance than C2Higher cost, limited zone availabilityPrefer over C2 for new deployments
E2 in production

E2 is fine for development, staging, and workloads where occasional CPU throttling is acceptable. It is not a safe choice for user-facing services with latency requirements. If your service needs predictable p99 response times, use N2 or higher. The cost difference is real, but so is the performance risk.

Which machine type to use by workload

Use these as starting points. Monitor actual usage after deployment and adjust based on real data, not what you think might happen under load.

  • Local dev or build server: e2-standard-2 or e2-standard-4. Cost over consistency: it does not matter if the CPU is occasionally shared.

  • Low-traffic web app or staging environment: e2-standard-2. You do not need dedicated CPU for a site getting a few hundred requests per day.

  • Production API backend with latency requirements: n2-standard-4 as a starting point. Dedicated vCPUs prevent unexpected tail latency at p99.

  • PostgreSQL or MySQL database: n2-highmem-4 or n2-highmem-8. Databases benefit from more RAM for buffer caches. The highmem ratio gets you enough memory without over-buying vCPUs.

  • CPU-heavy batch job (transcoding, rendering, simulation): c3-standard-8 or higher. The clock speed improvement over N2 actually matters for these workloads.

  • In-memory database or SAP HANA: M-series. If you genuinely need hundreds of GB to multiple TB of RAM, this is the only family that supports it.

  • ML training at scale: A2 or A3 with the appropriate GPU count. Do not attempt large model training on CPU-only VMs.

  • ML inference at low-to-medium scale: G2 with NVIDIA L4. The L4 is optimised for inference throughput at lower cost than A100.

Custom machine types

Standard machine types use fixed vCPU-to-memory ratios. Custom machine types let you specify exact values, useful when no preset fits your workload without wasting one of the two resources.

For example, if your application needs 6 vCPUs and 12 GB RAM, there is no exact preset match. Your options without a custom type:

  • n2-standard-4: 4 vCPUs, 16 GB (not enough CPU, extra RAM you do not need)
  • n2-standard-8: 8 vCPUs, 32 GB (more of everything than required)
  • n2-custom-6-12288: exactly 6 vCPUs and 12 GB RAM

Custom types are priced proportionally. You pay for exactly the vCPU and memory you request, which makes them cost-efficient when you know your requirements precisely. E2, N2, and N2D support custom machine types. C2 and memory-optimised families do not.

Custom types are most useful when:

  • Your application profile clearly does not match a standard ratio
  • You have measured actual usage and know the exact requirement
  • Wasted resources are significant at scale, across many long-running VMs

They add naming complexity and can be harder to reason about inside instance templates and infrastructure-as-code. For most early-stage workloads, a standard preset is simpler and close enough.

How to choose the right machine type

Follow this process rather than guessing upfront:

  1. Identify your workload type. Is it CPU-bound, memory-bound, or balanced? This narrows down the right family immediately.

  2. Choose the family. General purpose (E2, N2, N2D) for most workloads. Compute-optimised (C2, C3) if CPU throughput is the bottleneck. Memory-optimised (M-series) only if you genuinely need hundreds of GB of RAM.

  3. Choose the ratio. Standard for balanced workloads. Highmem for databases and caches. Highcpu for batch processing. Custom if no preset fits without meaningful waste.

  4. Start conservatively. It is easier and faster to resize up than to over-provision from day one. Start smaller and monitor.

  5. Monitor and resize. Use Cloud Monitoring to observe CPU and memory usage over time. Resize based on that data rather than intuition.

Tip

You can resize a stopped VM at any time. The process takes minutes, not hours. There is no penalty for getting the initial choice slightly wrong, so err on the smaller side and adjust after you have real usage data.

Common gcloud commands

List available machine types in your target zone before committing to a family. Not all types are available in every zone:

gcloud compute machine-types list --filter="zone:europe-west2-a"

Create a VM with a specific machine type. This is the most common starting point for production deployments:

gcloud compute instances create my-app-prod \
  --zone=europe-west2-a \
  --machine-type=n2-standard-4

Create a VM with a custom machine type when no preset fits your vCPU and RAM requirements without waste (N2, 6 vCPUs, 12 GB RAM):

gcloud compute instances create my-custom-vm \
  --zone=europe-west2-a \
  --machine-type=n2-custom-6-12288

Resize an existing VM. The VM must be stopped first. After setting the new type, start it again:

gcloud compute instances stop my-app-prod --zone=europe-west2-a

gcloud compute instances set-machine-type my-app-prod \
  --zone=europe-west2-a \
  --machine-type=n2-standard-8

gcloud compute instances start my-app-prod --zone=europe-west2-a
Tip

When creating your first VM, start with E2 for experimentation. Move to N2 once you have a workload worth measuring for production requirements.

Right-sizing with Cloud Monitoring and Recommender

The machine type you pick on day one is a hypothesis. Right-sizing is the process of testing that hypothesis with real usage data and adjusting based on evidence.

Signs your VM is over-provisioned:

  • Average CPU utilisation is consistently below 20%
  • RAM usage stays well below total capacity with no memory pressure
  • GCP Recommender surfaces a suggestion to downsize

Signs your VM is under-provisioned:

  • CPU spikes frequently above 80 to 90% at peak load
  • The OS reports memory pressure, swapping, or OOM kills
  • Response times are higher than expected with no obvious network or disk cause
# View CPU utilisation for a VM over the last 24 hours
gcloud monitoring read \
  "compute.googleapis.com/instance/cpu/utilization" \
  --filter='metric.labels.instance_name="my-app-prod"' \
  --interval="24h"

# List GCP-generated right-sizing recommendations
gcloud recommender recommendations list \
  --recommender=google.compute.instance.MachineTypeRecommender \
  --location=europe-west2-a \
  --project=my-project-id

GCP Recommender observes 30 days of usage and surfaces specific suggestions automatically, including estimated monthly savings. Check these before committing to a long-term machine type or signing a committed use discount.

For workloads that can tolerate interruption, switching to Spot VMs cuts costs by 60 to 91% regardless of machine type. That is often a larger saving than right-sizing the machine type alone.

Scale up vs scale out

A bigger machine type is not always the right answer. When a VM is under load, you have two choices:

  • Scale up: resize to a larger machine type, adding more vCPU and RAM on one VM
  • Scale out: run more VMs of the same size behind a load balancer
🏗️

Analogy

Scaling up is like buying a bigger truck to carry more cargo in one trip. Scaling out is like hiring more drivers with regular trucks. The second approach spreads the risk: if one truck breaks down, the others keep running. One very large VM is a single point of failure.

Four n2-standard-4 VMs give you the same total compute as one n2-standard-16, and if one VM fails, the others absorb traffic without interruption.

Managed instance groups with autoscaling let you do this automatically. GCP adds and removes VMs based on CPU usage or custom metrics. If your application is stateless, this approach is almost always preferable to running one very large VM.

If your application holds state locally and cannot be spread across multiple VMs, scaling up makes sense. But that constraint is worth revisiting before committing to it permanently.

Common beginner mistakes

  1. Choosing a larger VM “just in case.” Over-provisioned VMs waste money every hour they run. Start with a smaller type, measure actual usage after a week, and upsize only when data justifies it.

  2. Using E2 for latency-sensitive production services. E2 vCPUs are shared and can be throttled under noisy-neighbour conditions. If your service has strict p99 latency requirements, use N2 or higher for dedicated, consistent CPU performance.

  3. Picking the wrong memory ratio. A database that needs 32 GB RAM but only 4 vCPUs fits an N2 highmem type. Using N2 standard forces you to buy 8 vCPUs just to reach 32 GB RAM, so you pay for CPU you do not need.

  4. Ignoring zone availability before choosing a family. Not all machine types are available in every zone. Run gcloud compute machine-types list filtered to your target zone before committing to a type in production infrastructure.

  5. Optimising only for vCPU count and ignoring RAM. Two VMs with the same vCPU count can have very different memory. A standard ratio gives you 4 GB per vCPU; a highmem gives you 8 GB. If your workload is memory-bound, vCPU count is not the number to optimise.

  6. Using C2 or C3 for I/O-bound workloads. High clock-speed CPUs provide no benefit when your application spends most of its time waiting on disk reads, database queries, or network responses. Use E2 or N2 instead, and invest the cost difference in faster persistent disks if disk is the real bottleneck.

  7. Never reassessing machine type after initial deployment. Your first choice is an estimate. GCP Recommender and Cloud Monitoring give you real data after 30 days. Most teams leave meaningful money on the table by never checking.

Frequently asked questions

What is a machine type in GCP?

A machine type defines the hardware shape of a Compute Engine VM: how many virtual CPUs it has and how much memory is allocated. Picking a machine type is essentially choosing the size of your server. The right choice depends on your workload: a web server has different needs from a database or a machine learning training job.

What is the difference between E2 and N2 machine types?

E2 uses shared-core processors that can be throttled under noisy-neighbour conditions. It is cost-optimised and suited for dev/test, low-traffic web servers, and workloads that do not need consistent CPU performance. N2 runs on Intel Cascade Lake with dedicated vCPUs and predictable performance. N2 costs more but is the right choice for production workloads with latency requirements. Start with E2, move to N2 when you have evidence you need consistent CPU.

When should I use C2 or C3 machine types?

C2 and C3 are compute-optimised, meaning they prioritise CPU clock speed over memory. Use them for CPU-bound tasks: scientific simulations, game servers, video transcoding, and numerical computing. They are not cost-effective for workloads that are mostly waiting on I/O, databases, or network. An E2 or N2 will give you the same throughput at lower cost.

What is a custom machine type in Compute Engine?

A custom machine type lets you specify an exact vCPU count and memory amount instead of using a preset ratio. For example, n2-custom-6-12288 gives you 6 vCPUs and 12 GB RAM. This is useful when a standard ratio wastes either CPU or memory for your specific workload. E2, N2, and N2D support custom types. They are priced proportionally to the resources you specify.

How do I know if my VM is too big or too small?

Check CPU utilisation and memory usage in Cloud Monitoring. If average CPU stays below 20% and memory pressure is low, the VM is likely over-provisioned. If CPU frequently spikes above 80% or the OS reports memory pressure or swapping, it is under-provisioned. GCP Recommender also surfaces right-sizing suggestions automatically based on 30 days of observed usage.

Last verified: 22 March 2026 Cloud services change frequently. Verify details against official documentation before making infrastructure decisions.