<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://openlakehouse.io/w/index.php?action=history&amp;feed=atom&amp;title=Spark_Kubernetes_shuffle_storage</id>
	<title>Spark Kubernetes shuffle storage - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://openlakehouse.io/w/index.php?action=history&amp;feed=atom&amp;title=Spark_Kubernetes_shuffle_storage"/>
	<link rel="alternate" type="text/html" href="https://openlakehouse.io/w/index.php?title=Spark_Kubernetes_shuffle_storage&amp;action=history"/>
	<updated>2026-12-06T00:13:54Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://openlakehouse.io/w/index.php?title=Spark_Kubernetes_shuffle_storage&amp;diff=189&amp;oldid=prev</id>
		<title>Open Lakehouse Wiki sync: Sync from open-lakehouse/wiki@7c9abaa</title>
		<link rel="alternate" type="text/html" href="https://openlakehouse.io/w/index.php?title=Spark_Kubernetes_shuffle_storage&amp;diff=189&amp;oldid=prev"/>
		<updated>2026-11-25T00:52:54Z</updated>

		<summary type="html">&lt;p&gt;Sync from open-lakehouse/wiki@7c9abaa&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Infobox concept&lt;br /&gt;
| name            = Spark Kubernetes shuffle storage&lt;br /&gt;
| also_known_as   = Spark local storage on Kubernetes, spark-local-dir volumes&lt;br /&gt;
| field           = Distributed data processing&lt;br /&gt;
| key_parts       = &amp;lt;code&amp;gt;emptyDir&amp;lt;/code&amp;gt; scratch volumes, &amp;lt;code&amp;gt;spark-local-dir-*&amp;lt;/code&amp;gt; volumes, on-demand persistent volume claims, &amp;lt;code&amp;gt;KubernetesLocalDiskShuffleDataIO&amp;lt;/code&amp;gt;&lt;br /&gt;
| implementations = [[Apache Spark]]&lt;br /&gt;
| related         = [[Shuffle]], [[Executor]], [[Spark on Kubernetes]], [[Executor decommissioning]], [[Spark Kubernetes pod template]]&lt;br /&gt;
}}&lt;br /&gt;
{{Verified|2026-11-23|the v4.3.0 tag of apache/spark (docs/running-on-kubernetes.md, docs/job-scheduling.md, docs/configuration.md, docs/core-migration-guide.md, deploy/k8s/Config.scala, KubernetesLocalDiskShuffleDataIO.scala) and SPARK-25262, SPARK-28042, SPARK-32971, SPARK-35182, SPARK-35416, SPARK-35593}}&lt;br /&gt;
&lt;br /&gt;
In [[Apache Spark]], &amp;#039;&amp;#039;&amp;#039;shuffle storage on Kubernetes&amp;#039;&amp;#039;&amp;#039; is the set of pod volumes where executors write [[shuffle]] files and spill data; by default these are Kubernetes &amp;lt;code&amp;gt;emptyDir&amp;lt;/code&amp;gt; volumes that last only as long as the executor pod.&amp;lt;ref name=&amp;quot;k8s&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/running-on-kubernetes.html |title=Running Spark on Kubernetes (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; Spark on Kubernetes has no external shuffle service, so shuffle files written by an [[Executor|executor]] are normally lost when its pod goes away.&amp;lt;ref name=&amp;quot;jobsched&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/job-scheduling.html |title=Job Scheduling (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; Spark offers RAM-backed volumes, host disks, persistent volume claims (PVCs) that the driver reuses, and a shuffle plugin that recovers files from reused PVCs.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Where does Spark write shuffle and spill data on Kubernetes by default? ==&lt;br /&gt;
When no volume is configured as local storage, Spark on Kubernetes mounts one &amp;lt;code&amp;gt;emptyDir&amp;lt;/code&amp;gt; volume for each directory in &amp;lt;code&amp;gt;spark.local.dir&amp;lt;/code&amp;gt; or the &amp;lt;code&amp;gt;SPARK_LOCAL_DIRS&amp;lt;/code&amp;gt; environment variable. If neither is set, Spark creates and configures a default directory.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An &amp;lt;code&amp;gt;emptyDir&amp;lt;/code&amp;gt; volume uses the ephemeral storage of the node and does not outlive the pod. Shuffle files on it disappear when the executor pod is deleted.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How does spark.kubernetes.local.dirs.tmpfs work? ==&lt;br /&gt;
&amp;lt;code&amp;gt;spark.kubernetes.local.dirs.tmpfs&amp;lt;/code&amp;gt; (default false, added in Spark 3.0.0) sets the medium of the scratch &amp;lt;code&amp;gt;emptyDir&amp;lt;/code&amp;gt; volumes to &amp;lt;code&amp;gt;Memory&amp;lt;/code&amp;gt;, so they are tmpfs, RAM-backed volumes.&amp;lt;ref name=&amp;quot;config&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/Config.scala |title=Config.scala (Kubernetes resource manager, v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{Cite web |url=https://issues.apache.org/jira/browse/SPARK-25262 |title=SPARK-25262: Support tmpfs for local dirs in k8s |publisher=Apache Software Foundation JIRA |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; The documentation suggests it for nodes without local disks, where many executors writing to network-mounted storage can be slow.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With tmpfs, data in the local directories counts against the pod&amp;#039;s memory. The Spark documentation suggests raising &amp;lt;code&amp;gt;spark.{driver,executor}.memoryOverheadFactor&amp;lt;/code&amp;gt; to leave room for it.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How do spark-local-dir volumes work? ==&lt;br /&gt;
Any volume mounted through the Spark volume properties whose name starts with &amp;lt;code&amp;gt;spark-local-dir-&amp;lt;/code&amp;gt; is used as local storage for shuffle and spill instead of the default &amp;lt;code&amp;gt;emptyDir&amp;lt;/code&amp;gt;.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt; Volume properties have the form &amp;lt;code&amp;gt;spark.kubernetes.executor.volumes.[VolumeType].[VolumeName].mount.path&amp;lt;/code&amp;gt;, and the supported types are &amp;lt;code&amp;gt;hostPath&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;emptyDir&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;nfs&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;persistentVolumeClaim&amp;lt;/code&amp;gt;.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;code&amp;gt;hostPath&amp;lt;/code&amp;gt; volume puts local directories on a directory of the node itself; support for mapping &amp;lt;code&amp;gt;spark.local.dir&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;hostPath&amp;lt;/code&amp;gt; volumes arrived in Spark 3.0.0.&amp;lt;ref&amp;gt;{{Cite web |url=https://issues.apache.org/jira/browse/SPARK-28042 |title=SPARK-28042: Support mapping spark.local.dir to hostPath volume |publisher=Apache Software Foundation JIRA |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; The Spark documentation warns that &amp;lt;code&amp;gt;hostPath&amp;lt;/code&amp;gt; volumes have known security weaknesses and advises cluster administrators to restrict them with the Pod Security Admission controller.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How do on-demand persistent volume claims work for shuffle? ==&lt;br /&gt;
Setting a volume&amp;#039;s &amp;lt;code&amp;gt;claimName&amp;lt;/code&amp;gt; option to &amp;lt;code&amp;gt;OnDemand&amp;lt;/code&amp;gt; makes Spark create one PVC per executor, with the size and storage class from the &amp;lt;code&amp;gt;sizeLimit&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;storageClass&amp;lt;/code&amp;gt; options.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt; Dynamic PVC creation and deletion for executors was added in Spark 3.1.0.&amp;lt;ref&amp;gt;{{Cite web |url=https://issues.apache.org/jira/browse/SPARK-32971 |title=SPARK-32971: Support dynamic PVC creation/deletion for K8s executors |publisher=Apache Software Foundation JIRA |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; The Spark documentation recommends a PVC named &amp;lt;code&amp;gt;spark-local-dir-*&amp;lt;/code&amp;gt; for jobs with large shuffles and sorts.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
spark.kubernetes.executor.volumes.persistentVolumeClaim.spark-local-dir-1.options.claimName     OnDemand&lt;br /&gt;
spark.kubernetes.executor.volumes.persistentVolumeClaim.spark-local-dir-1.options.storageClass  gp&lt;br /&gt;
spark.kubernetes.executor.volumes.persistentVolumeClaim.spark-local-dir-1.options.sizeLimit     500Gi&lt;br /&gt;
spark.kubernetes.executor.volumes.persistentVolumeClaim.spark-local-dir-1.mount.path            /data&lt;br /&gt;
spark.kubernetes.executor.volumes.persistentVolumeClaim.spark-local-dir-1.mount.readOnly        false&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Since Spark 4.2.0, the &amp;lt;code&amp;gt;ExecutorPVCResizePlugin&amp;lt;/code&amp;gt; plugin can grow the storage request of an executor&amp;#039;s &amp;lt;code&amp;gt;spark-local-dir-*&amp;lt;/code&amp;gt; PVCs while the executor runs. It is controlled by &amp;lt;code&amp;gt;spark.kubernetes.executor.pvc.resizeInterval&amp;lt;/code&amp;gt; (default 5 minutes), &amp;lt;code&amp;gt;resizeThreshold&amp;lt;/code&amp;gt; (default 0.5) and &amp;lt;code&amp;gt;resizeFactor&amp;lt;/code&amp;gt; (default 1.0), and requires a storage class that allows volume expansion.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;config&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Which configuration keys control PVC reuse? ==&lt;br /&gt;
Three driver properties let on-demand PVCs outlive the executor that first used them.&amp;lt;ref name=&amp;quot;config&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Property !! Added in !! Default in 4.3.0 !! Effect&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spark.kubernetes.driver.ownPersistentVolumeClaim&amp;lt;/code&amp;gt; || 3.2.0 || true || The driver pod, not the executor pod, owns on-demand PVCs&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spark.kubernetes.driver.reusePersistentVolumeClaim&amp;lt;/code&amp;gt; || 3.2.0 || true || The driver gives PVCs of deleted executors to new executors; requires driver ownership&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spark.kubernetes.driver.waitToReusePersistentVolumeClaim&amp;lt;/code&amp;gt; || 3.4.0 || false || The driver holds back new executors while it already owns as many PVCs as the job may have; requires both settings above&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The first two properties defaulted to false when they were introduced. Since Spark 3.4, the driver owns PVCs and tries to reuse those not attached to live executors; setting both properties to false restores the earlier behaviour.&amp;lt;ref name=&amp;quot;migration&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/core-migration-guide.html |title=Migration Guide: Spark Core (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; A pod in &amp;lt;code&amp;gt;Terminating&amp;lt;/code&amp;gt; state has not yet released its PVCs, so the total number of PVCs can exceed the number of running executors.&amp;lt;ref name=&amp;quot;config&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== What is KubernetesLocalDiskShuffleDataIO? ==&lt;br /&gt;
&amp;lt;code&amp;gt;org.apache.spark.shuffle.KubernetesLocalDiskShuffleDataIO&amp;lt;/code&amp;gt; is a built-in shuffle storage plugin that recovers shuffle data from reused PVCs, so a new executor that mounts a reused PVC tries to recover the shuffle data that dead executors left in its local directories.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;execcomp&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/resource-managers/kubernetes/core/src/main/scala/org/apache/spark/shuffle/KubernetesLocalDiskShuffleExecutorComponents.scala |title=KubernetesLocalDiskShuffleExecutorComponents.scala (v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; It was added in Spark 3.2.0 under SPARK-35593 and requires &amp;lt;code&amp;gt;spark.kubernetes.driver.reusePersistentVolumeClaim=true&amp;lt;/code&amp;gt;.&amp;lt;ref name=&amp;quot;plugin&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/resource-managers/kubernetes/core/src/main/scala/org/apache/spark/shuffle/KubernetesLocalDiskShuffleDataIO.scala |title=KubernetesLocalDiskShuffleDataIO.scala (v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{Cite web |url=https://issues.apache.org/jira/browse/SPARK-35593 |title=SPARK-35593: Support shuffle data recovery on the reused PVCs |publisher=Apache Software Foundation JIRA |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The documented setup mounts the PVC at a path such as &amp;lt;code&amp;gt;/data/spark-x/executor-x&amp;lt;/code&amp;gt; and sets &amp;lt;code&amp;gt;spark.shuffle.sort.io.plugin.class&amp;lt;/code&amp;gt; to the plugin class. The documentation also suggests enabling &amp;lt;code&amp;gt;spark.kubernetes.driver.waitToReusePersistentVolumeClaim&amp;lt;/code&amp;gt;.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How does shuffle storage relate to dynamic allocation and decommissioning? ==&lt;br /&gt;
Dynamic allocation needs shuffle files to survive executor removal. On other cluster managers the external shuffle service can do this, but Spark on Kubernetes does not support it, so setting &amp;lt;code&amp;gt;spark.shuffle.service.enabled&amp;lt;/code&amp;gt; to true is not an option there.&amp;lt;ref name=&amp;quot;jobsched&amp;quot; /&amp;gt; The remaining options are shuffle tracking (&amp;lt;code&amp;gt;spark.dynamicAllocation.shuffleTracking.enabled&amp;lt;/code&amp;gt;), shuffle block migration through [[executor decommissioning]], or a shuffle plugin whose driver components support reliable storage.&amp;lt;ref name=&amp;quot;jobsched&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;configdoc&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/configuration.html |title=Spark Configuration (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Decommissioning and PVC reuse address different failures. Decommissioning copies shuffle blocks from an executor that is being shut down to other executors, or to &amp;lt;code&amp;gt;spark.storage.decommission.fallbackStorage.path&amp;lt;/code&amp;gt;, before the pod ends.&amp;lt;ref name=&amp;quot;configdoc&amp;quot; /&amp;gt; PVC reuse with &amp;lt;code&amp;gt;KubernetesLocalDiskShuffleDataIO&amp;lt;/code&amp;gt; recovers files after a pod is already gone, as long as its PVC survives.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Shuffle]]&lt;br /&gt;
* [[Executor]]&lt;br /&gt;
* [[Executor decommissioning]]&lt;br /&gt;
* [[Spark Kubernetes pod template]]&lt;br /&gt;
* [[Spark on Kubernetes]]&lt;br /&gt;
* [[Kubernetes Operator for Apache Spark]]&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Navbox open lakehouse}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Concepts]]&lt;br /&gt;
[[Category:Glossary terms]]&lt;br /&gt;
[[Category:Apache Spark]]&lt;/div&gt;</summary>
		<author><name>Open Lakehouse Wiki sync</name></author>
	</entry>
</feed>