How Yahoo Optimizes Apache Spark with Flexible VMs

Yahoo operates a massive data infrastructure supporting hundreds of millions of users across finance, sports, and entertainment platforms. Their analytics workloads must run continuously at high speed, but relying on fixed virtual machine (VM) configurations created a brittle system: when a specific machine shape hit a regional capacity constraint, cluster provisioning in Managed Service for Apache Spark (formerly Dataproc) could stall critical data pipelines.

To solve this, Yahoo adopted flexible VM configurations in Managed Service for Apache Spark. The approach defines a ranked list of acceptable VM shapes and enables auto-zone placement, allowing the system to dynamically search regional zones for available capacity. This eliminated the need for manual intervention or custom retry logic when preferred machine types were out of stock.

Configuring flexible clusters requires several design rules. Auto-zone placement must be enabled by passing a region or an empty zone string so Managed Spark can search across the entire region. If autoscaling is used, all machine types in the flexible list must share similar core count and memory size to maintain a uniform CPU-to-memory ratio across primary and secondary workers. Mixed shapes may also require explicit YARN and Spark property overrides to keep resource allocations aligned with expected worker behavior.

Flexible configurations support large-scale workloads in two main ways: higher cluster creation success (Managed Spark selects from the ranked list instead of failing) and better regional resource use (auto-zone placement searches the entire region, reducing provisioning friction during high-demand periods). The configuration can be applied via gcloud or through the Dataproc API using the instanceFlexibilityPolicy field, enabling automation in pipelines and Airflow DAGs.

Yahoo reported that implementing flexible VMs reduced cluster provisioning failures caused by regional capacity stockouts by 85%. As Akshay Jain, Senior Software Developer Engineer at Yahoo, stated, ‘Moving to flexible VMs in Managed Service for Apache Spark has transformed our approach; instead of stalling when a specific machine shape faces capacity constraints, our clusters now automatically pivot to our ranked fallback options.’

Beyond provisioning reliability, the shift to a flexible compute stack transforms the environment into a dynamic pool that adapts to operational needs. It also facilitates hardware modernization by allowing teams to prioritize newer VM generations while keeping older types as reliable fallback options. Yahoo‘s broader data modernization journey included migrating on-premises Hadoop and big data estates to Google Cloud, establishing a cloud foundation capable of running high-scale batch and streaming analytics with dynamic resource flexibility.

How Yahoo Optimizes Apache Spark with Flexible VMs

View Original