Google PDE: Spark, Dataproc and Distributed Data Processing — Study Guide

Part of the Google Professional Data Engineer — Study Guide. Practice with verified answers in the Google exam hub, or take timed practice tests on ExamRoll.io.

Overview

Apache Spark on Google Cloud Dataproc provides a managed, elastic platform for distributed data processing. You can choose between long-running or ephemeral Dataproc clusters and Dataproc Serverless for Spark, depending on control needs, runtime variability, and management overhead. Spark offers resilient abstractions (RDDs), relational APIs (DataFrames and Spark SQL), and a fault-tolerant DAG execution engine optimized for iterative and batch ETL at scale. On Google Cloud, Cloud Storage replaces HDFS for durable, low-cost storage; the BigQuery connector enables direct analytical offload; and Dataproc Metastore centralizes schema management. Effective solutions align storage and compute lifecycles, tune Spark to the workload, instrument observability, and apply security with least privilege and network isolation.

Dataproc Architecture: Clusters, Serverless, Storage, and Metastore

Spark Model, Performance Tuning, and Reliability

Security, Observability, and Cost

Practical Problem Scenario

Acme Retail is migrating a 30-node on-prem Hadoop cluster running nightly Spark and Hive ETL that feeds downstream analytics. They want to reuse existing jobs with minimal changes, avoid managing clusters full-time, persist data beyond cluster lifetimes, and reduce storage cost.

Approach:

  1. Land data and metadata in managed services

    • Store all raw and curated data in Cloud Storage using Parquet with partitioning (for example, dt=YYYY-MM-DD).
    • Rationale: GCS is durable, low-cost, and decouples compute from storage so ephemeral clusters and serverless jobs can run without persistent disks. Partitioned Parquet enables predicate pushdown and efficient scans.
  2. Centralize the catalog with Dataproc Metastore

    • Migrate the Hive metastore to Dataproc Metastore. Create external Hive tables referencing GCS paths and retain existing schema/partition logic.
    • Rationale: A managed metastore allows multiple ephemeral clusters and serverless jobs to share table definitions without running an HA MySQL/PostgreSQL instance.
  3. Use ephemeral Dataproc clusters for batch ETL and workflow templates for orchestration

    • Define a workflow template that creates a cluster with the required image (for example, 2.1-debian11), runs Spark jobs (spark-sql and pyspark), and deletes the cluster on completion. Add initialization actions to install any custom libraries.
    • Rationale: Ephemeral clusters eliminate idle cost and isolate job dependencies. Workflow templates provide repeatability and parameterization (dates, input paths).
  4. Enable autoscaling and preemptible workers

    • Attach an autoscaling policy with a small core worker group and a larger pool of preemptible secondary workers; tune cooldowns to scale down promptly post-run.
    • Rationale: Core workers maintain cluster stability; preemptible workers absorb shuffles and wide transformations at lower cost. Spark/YARN retries handle lost tasks on preemption.
  5. Integrate with BigQuery via the Spark BigQuery connector

    • For dimension/fact loads, write Spark results to staging BigQuery tables, then run MERGE statements to update targets atomically. Where direct overwrite is safe, write partitioned tables using partition overwrite mode.
    • Rationale: BigQuery serves analytics and BI at scale; staging+MERGE yields transactional-like upserts from batch Spark, reducing downstream inconsistency.
  6. Tune Spark for performance and reliability

    • Set shuffle partitions relative to executor cores and enable AQE:
      --conf spark.sql.shuffle.partitions=600
      --conf spark.sql.adaptive.enabled=true
      
    • Use broadcast joins for small dimensions and checkpoint long lineages to GCS for stability.
    • Rationale: Proper partitioning reduces skew and scheduler overhead; AQE adapts to data profiles at runtime; checkpointing bounds recomputation after failures.
  7. Harden security and networking

    • Run clusters with dedicated service accounts granting only roles needed for GCS paths, the metastore, and BigQuery datasets. Create private IP clusters in a restricted subnet with Private Google Access and limit UI access via firewall rules.
    • Rationale: Least privilege and network isolation reduce attack surface; private control-plane egress avoids public exposure.
  8. Instrument logging, history, and alerts

    • Enable Spark event logs to GCS and deploy the History Server; route driver/YARN logs to Cloud Logging with retention. Add Monitoring alerts for long pending containers, repeated task failures, or excessive job duration.
    • Rationale: Centralized logs support root-cause analysis; proactive alerts detect skew, OOMs, or degraded I/O early.
  9. Modernize selectively with Dataproc Serverless for ad hoc and elastic spikes

    • Move sporadic or exploratory Spark SQL workloads to Dataproc Serverless; keep nightly pipelines on ephemeral clusters until fully validated on serverless.
    • Rationale: Serverless removes cluster ops and scales automatically, ideal for unpredictable loads; existing workflows continue with minimal code change.
  10. Validate object-store committers and small-file management

    • Set FileOutputCommitter algorithm v2 and compact outputs to 256–512 MiB per file via repartition/coalesce before writes.
    • Rationale: Object stores lack atomic rename; optimized committers reduce copy/rename overhead. Compaction mitigates the small-files problem for performance and cost.

This design reuses existing Spark and Hive jobs with minimal refactoring, ensures data durability in GCS, centralizes schemas, contains security blast radius, provides robust observability, and optimizes cost through ephemeral clusters, autoscaling, preemptible capacity, and targeted use of serverless execution.


Messaging · All domains · Data Ingestion

Practice these questions → · Timed practice on ExamRoll.io →

Pass the whole exam — not just this question

You found this answer. Get every verified question and explanation in one place, and save hours of prep. Free to start.

Pass your exam →

Browse Google →

Related guides

All-in-one access

One subscription. Every exam.

Every plan unlocks unlimited answer search, practice tests, AI explanations, and the full resource library — in 20+ languages.

Monthly
24.87
Just €0.83/day
Everything included:
  • Unlimited answer search
  • Unlimited practice tests
  • AI-powered explanations
  • Full resource library
  • 20+ languages
  • Weekly content updates
  • Rewards & referrals
  • Priority support
Start free trial

No credit card required*

Best value
12 months
179.87
Just €0.49/daySave 40%
Everything included:
  • Unlimited answer search
  • Unlimited practice tests
  • AI-powered explanations
  • Full resource library
  • 20+ languages
  • Weekly content updates
  • Rewards & referrals
  • Priority support
Start free trial

No credit card required*

✓ Free plan included · ✓ Cancel anytime · ✓ All plans unlock the full product