Skip to content

Google Cloud Dataproc Platform

Google Cloud Dataproc is Google Cloud’s fully managed Apache Spark and Hadoop service. BenchBox integrates with Dataproc to execute benchmarks on managed clusters, supporting both persistent and ephemeral cluster modes.

Features

  • Managed clusters - Automatic provisioning and monitoring
  • Flexible pricing - Per-second billing with preemptible VM support
  • GCS integration - Native Google Cloud Storage support
  • Auto-scaling - Dynamic cluster sizing based on workload
  • Hive Metastore - Managed metadata service support

Installation

Terminal window
uv add benchbox --extra cloud-spark-gcp

This installs the Dataproc dependencies, including google-cloud-dataproc and google-cloud-storage.

Prerequisites

  1. GCP Project with Dataproc API enabled
  2. GCS Bucket for data staging
  3. Service Account with the following roles:
    • roles/dataproc.editor - Create/manage clusters and jobs
    • roles/storage.objectAdmin - Read/write GCS objects
  4. Application Default Credentials configured

Configuration

CLI Usage

The BenchBox CLI does not accept the Dataproc project, staging, or cluster settings, so run Dataproc benchmarks through the Python API described below. The CLI can still preview the generated queries without connecting to Google Cloud:

Terminal window
benchbox run --platform dataproc --benchmark tpch --dry-run ./preview

Adapter Options

These are DataprocAdapter keyword arguments.

OptionDefaultDescription
project_idrequiredGCP project ID
gcs_staging_dirrequiredGCS path for data staging
regionus-central1GCP region
cluster_nameauto-generatedDataproc cluster name
databasebenchboxHive database name
master_machine_typen2-standard-4Master VM type
worker_machine_typen2-standard-4Worker VM type
num_workers2Number of worker nodes
use_preemptible_workersfalseUse preemptible workers
create_ephemeral_clusterfalseCreate/delete cluster per job
timeout_minutes60Job timeout in minutes

Machine Types

TypevCPUMemoryCost/HourBest For
n2-standard-4416GB~$0.20General workloads
n2-standard-8832GB~$0.39Larger datasets
n2-highmem-4432GB~$0.26Memory-intensive
n2-highmem-8864GB~$0.52Large joins/aggregations
c2-standard-4416GB~$0.21CPU-intensive

Preemptible VMs: ~80% cheaper but can be interrupted

Python API

from benchbox.platforms.gcp import DataprocAdapter
adapter = DataprocAdapter(
project_id="my-project",
region="us-central1",
cluster_name="my-cluster",
gcs_staging_dir="gs://my-bucket/benchbox/",
database="tpch_benchmark",
num_workers=4,
)
adapter = DataprocAdapter(
project_id="my-project",
gcs_staging_dir="gs://my-bucket/benchbox/",
create_ephemeral_cluster=True,
use_preemptible_workers=True,
)
adapter.create_schema("tpch_sf1")
adapter.load_data(
tables=["lineitem", "orders", "customer"],
source_dir="/path/to/tpch/data",
)
result = adapter.execute_query("SELECT COUNT(*) FROM lineitem")
adapter.close()

The first adapter connects to an existing cluster. The second creates an ephemeral cluster. The calls then create the schema in Hive, load data to GCS and create the Hive tables, submit the query as a Dataproc job, and clean up on close() (which deletes the ephemeral cluster if one is configured).

Cluster Modes

Persistent Cluster

Best for ongoing development and multiple benchmark runs:

adapter = DataprocAdapter(
project_id="my-project",
cluster_name="benchmark-cluster",
gcs_staging_dir="gs://bucket/benchbox/",
)
  • Reuse cluster across jobs
  • Faster job submission (no cluster startup)
  • Pay for cluster uptime

Ephemeral Cluster

Best for one-off benchmarks and CI/CD:

adapter = DataprocAdapter(
project_id="my-project",
gcs_staging_dir="gs://bucket/benchbox/",
create_ephemeral_cluster=True,
)
  • Cluster created when first job is submitted
  • Cluster deleted on adapter.close()
  • Pay only for actual usage

Spark Configuration

BenchBox automatically optimizes Spark configuration based on benchmark type and scale factor. The automatic configuration covers:

  • Adaptive Query Execution (AQE) settings
  • Shuffle partition tuning
  • Memory allocation
  • Join optimization

For TPC-H at SF=10 with 4 workers, the settings include spark.sql.shuffle.partitions = 200, spark.sql.adaptive.enabled = true and spark.sql.adaptive.skewJoin.enabled = true.

Cost Estimation

Scale FactorData SizeWorkersEst. RuntimeEst. Cost
0.01~10 MB2x n2-std-4~30 min~$0.30
1.0~1 GB2x n2-std-4~2 hours~$1.20
10.0~10 GB4x n2-std-8~4 hours~$6.24
100.0~100 GB8x n2-std-8~8 hours~$24.96

With preemptible workers: reduce worker costs by ~80%

IAM Configuration

Minimum required IAM roles:

Terminal window
gcloud projects add-iam-policy-binding PROJECT_ID \
--member="serviceAccount:SA_EMAIL" \
--role="roles/dataproc.editor"
gcloud projects add-iam-policy-binding PROJECT_ID \
--member="serviceAccount:SA_EMAIL" \
--role="roles/storage.objectAdmin"
gcloud projects add-iam-policy-binding PROJECT_ID \
--member="serviceAccount:PROJECT_NUMBER-compute@developer.gserviceaccount.com" \
--role="roles/dataproc.worker"

The first two bindings are for the service account that runs BenchBox. The third is for the Dataproc worker service account.

Troubleshooting

Common Issues

Cluster creation fails:

  • Verify Dataproc API is enabled
  • Check service account permissions
  • Ensure region has available quota

Job fails to start:

  • Check cluster is in RUNNING state
  • Verify GCS bucket is accessible
  • Review job logs in Dataproc console

Slow performance:

  • Increase number of workers
  • Use larger machine types
  • Enable preemptible secondary workers
  • Check for data skew in queries

GCS access denied:

  • Verify service account has Storage Object Admin role
  • Check bucket and object permissions
  • Ensure bucket is in same project or cross-project access is configured

Comparison with Other Platforms

AspectDataprocAWS EMRAzure HDInsight
PricingPer-secondPer-secondPer-minute
PreemptiblePreemptible VMsSpot InstancesLow-priority VMs
StorageGCSS3/HDFSADLS/Blob
MetastoreDataproc MetastoreAWS Glue CatalogHive Metastore
ScalingManual/AutoAutoManual