Configuring Spark jobs for large shuffle data

Learn about configuring the Spark jobs to use the persistent volumes for shuffle data to improve the performance or handle the huge shuffle data.

Default behavior

By default, Cloudera Data Engineering writes shuffle data to the root volume of the node. It does not use a persistent volume for shuffle data.

This works when the root volume is large and fast enough for the workload. If it is not, give each executor its own persistent volume. See Configuring and sizing per-executor volumes (PVC).

Supported storage

These recommendations apply to both the root volume and per-executor volumes. Use SSD-class block storage. Spark writes shuffle data to a directory. The device type does not affect compatibility. It affects throughput.

Platform Supported Storage
AWS EBS
OpenStack Cinder
Azure Managed Disks
GCP Persistent Disk / Hyperdisk

Local NVMe disks attached directly to the nodes (AWS instance store, GCP Local SSD, Azure local/temp NVMe) are also supported wherever the nodes provide them.

Sizing node-local disk

Size the node-local disk against the peak concurrent shuffle write across the cluster: provision about 2.5 times that peak. The extra space over the raw shuffle size covers:

  • Spill. When executors are short on memory, spill files share the disk with the shuffle output. Measured disk usage has reached 1.9 times the shuffle size.

  • Eviction threshold. Kubernetes starts evicting pods when the disk is about 85% full.

  • Container images, logs and the driver use the same disk. Reserve about 10 GB per node for them, in addition to the space above.

If partition counts are reasonable and executors do not spill, about 1.2 times the shuffle write is enough.

Configuring and sizing per-executor volumes (PVC)

If the root volume is too small or too slow, configure the job to use per-executor volumes. Each executor then writes its shuffle data to its own volume instead of the node's root volume. The failure mode is also safer: a full volume fails one task, instead of Kubernetes evicting every pod on the node.

Configuring the volume

Add these Spark properties to the job:

spark.kubernetes.executor.volumes.persistentVolumeClaim.spark-local-dir-1.options.claimName=OnDemand
spark.kubernetes.executor.volumes.persistentVolumeClaim.spark-local-dir-1.options.storageClass=<storage class>
spark.kubernetes.executor.volumes.persistentVolumeClaim.spark-local-dir-1.options.sizeLimit=<volume size>
spark.kubernetes.executor.volumes.persistentVolumeClaim.spark-local-dir-1.mount.path=/data
spark.kubernetes.executor.volumes.persistentVolumeClaim.spark-local-dir-1.mount.readOnly=false
  • OnDemand creates one volume per executor. Each volume is deleted when its executor ends.
  • storageClass selects the storage. Cloudera tested ebs-sc on AWS and block-storage (Cinder) on OpenStack. Use the storage class names in your cluster.
  • sizeLimit sets the size of each volume. To choose a value, see the next section.

Sizing the volume

Per-executor volumes are not shared between jobs. Base the size on the shuffle write of that job only.

Budget about 3 times the job's shuffle write. Divide that total by the job's number of executors to get the sizeLimit value.

Example: A job's shuffle write is 750 GB and the job runs 13 executors.

750 GB × 3 = 2,250 GB. 2,250 GB ÷ 13 ≈ 173 GB. Set sizeLimit=200Gi.

The 3x figure is a result of Cloudera’s tests. It allows for two things:

  • Uneven work. Executors cannot share capacity, so each volume must fit the busiest executor. In testing, an executor alone on a node wrote 1.7 times as much as the others.

  • Failures. If an executor is lost during a stage, Spark rewrites that executor's output onto the remaining volumes. In one test, three lost executors raised the total written to 1.5 times the clean size.

If the job has no executor failures and each executor does the same amount of work, about 1.9 times the job's shuffle write is enough. This includes room for spill.