Using Flexible VMs to Keep Apache Spark Pipelines Running

The article explains how teams running Apache Spark can stay resilient when cloud compute capacity runs short, focusing on Google’s Managed Service for Apache Spark and its support for flexible VMs. As AI development drives global demand for compute, capacity stockouts occur when demand for a specific machine family such as N2 or N2D exceeds available capacity in a target zone or region. For time-sensitive pipelines, rigid single-VM requirements make provisioning a single point of failure, leading to cluster creation delays, failed executions, and potential SLA breaches.

Flexible VMs change how a Managed Spark cluster requests compute resources. Instead of binding a cluster to one instance type, teams define an ordered list of acceptable machine families for master, primary worker, and secondary worker nodes. Key features include multi-family blending, which mixes nodes across generations such as Gen2 families (N2, N2D) and Gen4 families (N4, C4) in one configuration; mixed storage support, which lets storage options adapt to the host family’s supported disk types; and comprehensive cluster coverage, which applies flexible rules to primary workers, secondary preemptible/spot workers, and master nodes.

A successful strategy depends on intentional ranking. Managed Spark clusters automatically attempt provisioning in priority order, mitigating stockout risk without manual intervention. The recommendation is to specify at least two machine families at the highest priority, Rank 0. For production pipelines standardized on n2d-standard-16, the article suggests a tiering strategy: Rank 0 with n2d-standard-16 and n2-standard-16 using standard Local SSD or PD; Rank 1 with n4-standard-16 and n4d-standard-16 using Hyperdisk Balanced; Rank 2 with c4-standard-16 and c3-standard-22 using Hyperdisk Balanced; and Rank 3 with e2-standard-16 using standard PD. For legacy n1-standard-16 workloads, a separate tiering path transitions toward newer architectures while preserving stability, mixing n1-standard-16 and n2-standard-16 at Rank 0, then n2d-standard-16, then n4/n4d families with Hyperdisk Balanced, and finally e2-standard-16.

Adopting newer instance families often requires modern storage such as Hyperdisk Balanced, since N4 and C4 families rely on Hyperdisk for predictable performance across variable VM sizes. The article notes that starting with default IOPS and throughput settings is usually a reliable baseline for most distributed Spark jobs.

Several trade-offs need evaluation. Resource quotas must cover all machine types and disks in the flexible VM list, not just one family. Traditional resource-based Committed Use Discounts are tied to specific machine families, so teams should adopt Compute flexible CUDs to apply savings across multiple families and regions. Performance can differ across generations and between Local SSD and Hyperdisk, so testing specific Spark jobs is essential to understand SLA impact.

The article closes with additional recommendations: use AutoZone routing to let Managed Spark select the best zone based on current capacity; prefer smaller machine shapes such as 4, 8, or 16 cores because they are easier to fulfill from the on-demand pool; deploy cluster autoscaling with reasonable maxInstances; configure a minimum acceptable number of primary workers so clusters can start under constraints and scale later; and set up regional fallbacks to reduce risk in high-demand regions like us-central1. Together, flexible VMs and these complementary practices help keep critical Spark pipelines operational during regional or zonal hardware shortages.

Maximize Apache Spark availability with flexible VMs

View Original