Skip to main content

Creating a cluster with Compute Engine

Exam guide§2.1

Following the cluster-creation blueprint, this page works through the choices you make when implementing a cluster on Compute Engine (GCE): the machine type that carries the workload, the deployment option that provisions it, the network setup for accelerators, and the reference architecture that ties it all together.

Choosing a machine type

The first implementation choice is the machine type - the VM family that carries the workload. Families sit on a spectrum from less demanding, cost-sensitive work to performance-intensive HPC and AI, split into general purpose and workload optimized categories.

Spectrum of GCE VM families from less demanding to performance-intensive workloads, split into General Purpose (E2, N1/N2/N2D, C3/C3D/C3A, T2D/T2A) and Workload Optimized (C2/C2D/H3, M1/M2/M3, A2/A3/G2).
GCE VM families across the workload spectrum, from cost-optimized general purpose to performance-intensive workload optimized.

General purpose VM families

For a broad range of everyday workloads where cost-effectiveness and flexibility matter more than raw single-core performance.

ProfileTypical workloadsE2Low-cost, cost-optimized - best for lessdemanding tasksDev/test environments, low-traffic webservers, back-office appsN1, N2, N2DThe workhorses - a great balance ofperformance and flexibilityDatabases, business intelligence apps,high-traffic web serversC3, C3D, C3AConsistently high performance and betterprice-performanceAds servers, data analyticsT2D, T2AScale-out - excellent performance perdollar for horizontally scaled appsMedia transcoding, microservices
General purpose VM families - balanced, cost-effective everyday compute.

Workload optimized VM families

For specialized, demanding workloads that need a specific type of performance - designed for HPC and AI.

OptimizationTypical workloadsC2, C2D, H3Compute-optimized - highest performanceper core (H3 tuned for tightly-coupledHPC)HPC, scientific modeling, electronicdesign automation (EDA)M1, M2, M3Memory-optimized - very highmemory-to-vCPU ratioLarge in-memory databases (SAP HANA),in-memory analyticsA2, A3Accelerator-optimized - NVIDIA's mostpowerful GPUs (A100 on A2, H100 on A3)AI/ML model training, massively parallelcomputation, scientific simulationG2Accelerator-optimized - NVIDIA L4 GPUs,balanced cost and performanceAI inference, media transcoding,flash-optimized databases
Workload optimized VM families - specialized for compute, memory, or accelerators.

Accelerator OS images

When provisioning accelerator machine types (those with pre-attached GPUs), you must specify an operating system (OS) image. Beyond the standard OS suite, Google Cloud offers a specialized set of accelerator OS images tuned for high-performance AI workloads - they ship with the drivers and dependencies for full accelerator functionality out of the box, so the correct, compatible drivers are installed the moment the VM launches.

FactsWhat accelerator OS images bundle
  • GPU drivers - such as NVIDIA drivers, critical for enabling the accelerator hardware.
  • Networking drivers - such as Mellanox drivers, which support the high-speed networking (including RDMA) required for distributed AI.

Two OS bases are available - Rocky Linux:

Image familyMachine seriesRocky Linux 9 acceleratorrocky-linux-9-optimized-gcp-nvidia-570A4, A3 UltraRocky Linux 8 acceleratorrocky-linux-8-optimized-gcp-nvidia-570A4, A3 Ultra
Rocky Linux accelerator OS images.

and Ubuntu LTS:

Image familyArchitectureMachine seriesUbuntu 24.04 LTS acceleratorubuntu-accelerator-2404-amd64-with-nvidia-570x86A4, A3 UltraUbuntu 24.04 LTS acceleratorubuntu-accelerator-2404-amd64-with-nvidia-570ArmA4XUbuntu 22.04 LTS acceleratorubuntu-accelerator-2404-amd64-with-nvidia-570x86A4, A3 UltraUbuntu 22.04 LTS acceleratorubuntu-accelerator-2404-amd64-with-nvidia-570ArmA4X
Ubuntu LTS accelerator OS images.
GotchaThe image family is what you pass at creation

The image family is the identifier you use when creating instances - not a loose OS name. The right one depends on your machine series (e.g. A3, A4) and architecture (x86 or Arm). For the full list, see the Operating system details page in the Compute Engine documentation.

DECISIONWhich VM family?

Match the family to what the workload is bound by. General purpose (E2, N1/N2/N2D, C3, T2D) trades raw performance for cost and flexibility; workload optimized families specialize - compute (C2/H3), memory (M-series), or accelerators (A-series for training, G2 for inference).

Pick this when: Cost-sensitive dev/test or low-traffic web → E2 | balanced everyday workloads → N1/N2/N2D | compute-bound HPC/EDA → C2/C2D/H3 | large in-memory databases → M1/M2/M3 | AI/ML training → A2/A3 | AI inference → G2

Choosing a deployment option

Deploying a cluster on Compute Engine offers three deployment types, each with a different level of control versus automation. The right one depends on your workload and your team's expertise.

What it isBest forDirect VM managementProvision and manage VMs yourself -single instances, bulk instances, ormanaged instance groups (MIGs)Full control; from quick single-nodetests to self-healing autoscalingclustersOrchestrated frameworksA scheduler manages the cluster foryou (e.g. Cluster Toolkit provisioningSlurm via Terraform)Reproducible HPC environments withbest practices baked in - a balance ofcontrol and automationFully managed servicesThe highest level of abstraction(Vertex AI) - you focus on the model,Google runs the infrastructureTeams that want to skip infrastructuremanagement entirely
The three GCE deployment types, by what they are and what they suit.

Within direct VM management, the granularity itself is a choice:

FactsDirect VM management sub-options
  • Single instance - the simplest way to get one GPU or TPU running. Ideal for quick tests, development, or single-node inference.
  • Bulk instances - create a fixed number of nodes all at once. Manual but efficient when you know the exact cluster size you need.
  • Managed instance groups (MIGs) - automate creation and management of a group of identical VMs, with autoscaling (by schedule or custom metric) and self-healing.
DECISIONMIGs are the pick for stateful, high-availability serving

When you need a cluster that scales automatically and repairs itself - for example a stateful inference service under variable demand, or large-scale batch processing - reach for MIGs, not bulk instances. Bulk instances are a fixed set with no autoscaling or self-healing.

Pick this when: need autoscaling + self-healing -> MIGs; fixed batch set, no autoscale needed -> bulk instances

Cluster Toolkit

The Cluster Toolkit is a modular, composable toolkit written in Terraform for deploying repeatable, turnkey HPC environments on Google Cloud with best practices built in.

Cluster Toolkit flow: a blueprint fans out to Scheduler, Storage, and Compute modules, which deploy together into a running deployment.
The Cluster Toolkit: a blueprint references modules (scheduler, storage, compute) that deploy into your HPC infrastructure.
FactsCluster Toolkit components
  • Blueprint - the design your HPC environment is built to follow. Can be workload-specific, general purpose, or partner-focused; several examples ship with the toolkit, and you can customize or build your own.
  • Modules - reusable building blocks the blueprint references, grouped by type (scheduler, storage, compute).
  • Deployment - the modules deploy into the HPC infrastructure and run your workloads.

Demo: deploying an HPC cluster with Slurm

Deploy an HPC cluster with Slurm

The demo enables the required APIs, clones the toolkit from GitHub, builds its binary, then uses a YAML blueprint with ghpc create and ghpc deploy to provision a Slurm cluster via Terraform. It finishes by connecting to the login node and running a sample job with srun, then a batch job with sbatch - Slurm spins up a compute node per job and removes it once idle, keeping costs down.

Networking for GCE instances

Accelerator-optimized machine types often need a specialized multi-VPC network configuration - regardless of whether you create standalone VMs, bulk instances, or MIGs. Separating traffic types keeps the high-bandwidth accelerator path from being congested by general system traffic.

Two GPU hosts connected by two links: a red link for general host-to-host traffic and a blue link for high-bandwidth GPU-to-GPU communication.
A multi-VPC setup segregates general host-to-host traffic from the dedicated high-bandwidth GPU-to-GPU path.
FactsTraffic types to segregate
  • General host-to-host traffic - standard networking for system operations and general data transfer.
  • High-bandwidth GPU-to-GPU communication - dedicated, low-latency pathways for performance-intensive tasks that involve direct communication between accelerators on different VMs.
GotchaRequirements vary by machine type and accelerator

The separation ensures critical high-bandwidth traffic isn't congested by general system traffic - but the specific network requirements and optimal configuration depend on the chosen machine type and accelerator. There is no single layout.

Placement policies

By default, when you create VMs you only specify their zone. For latency-sensitive applications that need VMs physically close together, placement policies act like a seating arrangement that puts your VMs "in the same room" instead of on opposite sides of a crowded stadium. Which policy you use depends on how the VMs were created:

Applies toGuaranteeCompact placement policyIndividual VMs or bulk-created VMsBest-effort - places VMs as close aspossibleWorkload policyManaged instance groups (MIGs)Can enforce strict colocation for maximumperformance
Placement policies by the VMs they apply to and the guarantee they give.

Compact placement policies tell Compute Engine "place these VMs as close as possible" - a best-effort attempt. For applications where every millisecond counts, the maxDistance field tightens that further.

GotchaLower maxDistance is closer, but riskier to create

A lower maxDistance value packs the VMs closer together, but it also increases the chance that some VMs fail to be created if the space isn't available. You are trading placement guarantees against capacity availability.

Workload policies are a specialized "seating chart" for a MIG - you define the type of work the VMs do and how they should be physically arranged:

NumbersConfiguring a workload policy
  • Workload type - for low-latency needs, specify a high-throughput workload type, and Compute Engine tries to place the MIG's VMs as close as possible.
  • Strict colocation - the maxTopologyDistance field sets a maximum physical distance between VMs. If it can't be met, the MIG won't create the VMs - an all-or-nothing deal for ultimate performance.
  • Accelerator topology - for workloads using GPUs with an inter-accelerator network (e.g. A4X VMs with NVLink), places VMs to optimize the high-speed connections between accelerators.

Demo: exploring compact placement policies

Explore compact placement policies for Compute Engine VMs

The demo creates a policy with gcloud compute resource-policies create using --collocation=COLLOCATED, attaches it to two identical n2-standard-8 VMs via --resource-policies, then runs gcloud compute instances describe on each. The physical host location strings come back identical - confirming both VMs land on the same host for the lowest possible network latency.

DECISIONCompact placement policy or workload policy?

Both minimize network latency by physically co-locating VMs. Compact placement policies apply to individual/bulk VMs and are best-effort. Workload policies apply to MIGs and can enforce strict colocation for maximum performance.

Pick this when: Individual or bulk VMs → compact placement policy (best-effort, tune with maxDistance) | managed instance group → workload policy (can enforce strict colocation via maxTopologyDistance)

Reference architecture

Building high-performance AI/ML infrastructure on Compute Engine is more than spinning up a VM - it is designing an ecosystem that supports the whole workload lifecycle, from data ingestion to model serving. In this architecture, compute nodes are segmented into partitions by purpose and hardware.

AI infrastructure reference architecture on Compute Engine: on-prem users connect via Cloud Interconnect / Cloud VPN to interactive and administrative nodes, GPU/TPU/CPU compute partitions, Cloud Storage and parallel file systems, plus Operations Suite and BigQuery/Dataflow analytics.
AI infrastructure reference architecture on Compute Engine - connectivity, access nodes, compute partitions, storage, operations, and analytics.

Connectivity

An AI architecture is often hybrid, with some components on-premises. A secure, high-speed connection ties the two together.

What it isTrade-offCloud InterconnectA private, dedicated fiber-optic linkbetween your on-prem network and Google'snetworkDirect, low-latency, high-bandwidthCloud VPNAn encrypted tunnel over the publicinternetMore flexible and cost-effective, butperformance varies with internet traffic
Hybrid connectivity options - dedicated Interconnect versus encrypted VPN.

Access nodes

  • Interactive nodes - specialized workstations for administrative tasks and real-time interaction. For Linux VMs you can use a bastion host: a hardened, dedicated GCE VM that is the single controlled external entry point into the private cluster network.
  • Administrative nodes - SSH login nodes and a cluster manager, where administrators and data scientists log in to manage the infrastructure and run quick ad-hoc tasks.

Compute nodes

The core engine room - large-scale worker nodes optimized for intense, parallelizable tasks, split into accelerator partitions.

NumbersCompute partitions
  • GPU nodes - training and inference, with GPUs such as the NVIDIA H100 (e.g. the A3 H100 partition).
  • TPU nodes - massive, data-parallel training jobs on Google's custom ML silicon (e.g. a TPU v4-16 partition).
  • CPU nodes - general-purpose workhorses for data preprocessing, pre-/post-processing, and inference on non-accelerator models.

Storage

A slow storage system bottlenecks even the fastest GPUs, so the architecture separates cold/archive storage from high-speed parallel access.

FactsStorage tiers
  • Parallel file systems (PFS) - the high-speed "scratchpad" for active workloads (e.g. DDN EXAScaler, IBM Spectrum Scale), distributing data across storage servers for high throughput and low latency.
  • Cloud Storage - the main data warehouse: scalable, durable object storage for raw training data, model checkpoints, and results.
  • Cloud Storage FUSE - mounts a GCS bucket as a local file system, exposing GCS data to compute nodes without copying it.

Operations and analytics

  • Operations Suite - mission control: Logging and Monitoring track cluster and workload health (GPU utilization, pod errors, system logs) and surface issues proactively. It also covers VM rightsizing.
  • Data analytics - BigQuery (serverless data warehouse) analyzes large datasets, and Dataflow (managed ETL/processing) transforms data - both for pre-processing training data and analyzing model results.

Increasing cluster security with IAP

A bastion host is a valid way to manage access, but Google Cloud offers a managed, zero-trust alternative: Identity-Aware Proxy (IAP). Instead of a publicly exposed VM, IAP controls access to internal VMs based on user identity and IAM policies, not network location.

GotchaIAP keeps compute nodes fully private

IAP SSH tunneling routes SSH-port traffic through Google's network edge directly to the VM's internal IP. High-value compute nodes stay completely private while data scientists still connect with a simple gcloud compute ssh - provided they hold the correct IAM permissions. No public bastion required.

DECISIONCloud Interconnect or Cloud VPN?

For regularly transferring multi-terabyte datasets from on-prem to Cloud Storage, Cloud Interconnect is the choice - its dedicated, high-throughput, low-latency link bypasses the public internet for faster, more reliable transfers. Cloud VPN saves cost and adds flexibility, but its performance over the public internet is too variable for reliable large-scale transfers.

Pick this when: Regular multi-terabyte transfers / consistent high throughput → Cloud Interconnect (dedicated, bypasses public internet) | flexible, cost-sensitive, tolerant of variable performance → Cloud VPN