<?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=Dynamic_allocation</id>
	<title>Dynamic allocation - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://openlakehouse.io/w/index.php?action=history&amp;feed=atom&amp;title=Dynamic_allocation"/>
	<link rel="alternate" type="text/html" href="https://openlakehouse.io/w/index.php?title=Dynamic_allocation&amp;action=history"/>
	<updated>2026-12-06T00:07:29Z</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=Dynamic_allocation&amp;diff=142&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=Dynamic_allocation&amp;diff=142&amp;oldid=prev"/>
		<updated>2026-11-25T00:52:40Z</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            = Dynamic allocation&lt;br /&gt;
| also_known_as   = Dynamic resource allocation, &amp;lt;code&amp;gt;spark.dynamicAllocation&amp;lt;/code&amp;gt;&lt;br /&gt;
| field           = Distributed data processing&lt;br /&gt;
| introduced      = Apache Spark 1.2.0; shuffle tracking (no external shuffle service needed) in 3.0.0&lt;br /&gt;
| key_parts       = Request policy (backlog timeouts, exponential ramp-up), remove policy (idle timeouts), shuffle data preservation&lt;br /&gt;
| implementations = [[Apache Spark]] on standalone, YARN and Kubernetes&lt;br /&gt;
| related         = [[Executor]], [[External shuffle service]], [[Shuffle]], [[Caching and persistence]]&lt;br /&gt;
}}&lt;br /&gt;
{{Verified|2026-11-23|the v4.3.0 tag of apache/spark (docs/job-scheduling.md, docs/configuration.md, docs/running-on-kubernetes.md) and SPARK-27963}}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Dynamic allocation&amp;#039;&amp;#039;&amp;#039; is an [[Apache Spark]] feature that adds [[executor]]s to an application when tasks are waiting and removes executors that sit idle, so that an application holds only the resources its current work needs. It is off by default (&amp;lt;code&amp;gt;spark.dynamicAllocation.enabled=false&amp;lt;/code&amp;gt;) and works on the standalone, YARN and Kubernetes cluster managers.&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#dynamic-resource-allocation |title=Job Scheduling: Dynamic Resource Allocation (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; Because removing an executor would also remove the [[shuffle]] files it wrote, dynamic allocation needs a way to keep shuffle data available: an [[external shuffle service]], shuffle tracking, shuffle block migration or a shuffle storage plugin.&amp;lt;ref name=&amp;quot;jobsched&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How does dynamic allocation scale executors? ==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Adding executors.&amp;#039;&amp;#039;&amp;#039; When tasks have been pending for &amp;lt;code&amp;gt;spark.dynamicAllocation.schedulerBacklogTimeout&amp;lt;/code&amp;gt; (default 1s), Spark requests more executors, and it requests again every &amp;lt;code&amp;gt;spark.dynamicAllocation.sustainedSchedulerBacklogTimeout&amp;lt;/code&amp;gt; (default: the same value) while the backlog lasts. Each round asks for twice as many as the last: 1, then 2, 4, 8 and so on. The Spark docs compare this to TCP slow start: cautious at first, but able to ramp up quickly.&amp;lt;ref name=&amp;quot;jobsched&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;config&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/configuration.html#dynamic-allocation |title=Spark Configuration: Dynamic Allocation (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Removing executors.&amp;#039;&amp;#039;&amp;#039; An executor that has been idle for &amp;lt;code&amp;gt;spark.dynamicAllocation.executorIdleTimeout&amp;lt;/code&amp;gt; (default 60s) is removed. Executors that hold cached data are kept by default, because &amp;lt;code&amp;gt;spark.dynamicAllocation.cachedExecutorIdleTimeout&amp;lt;/code&amp;gt; is infinite.&amp;lt;ref name=&amp;quot;jobsched&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;config&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Setting !! Default&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spark.dynamicAllocation.enabled&amp;lt;/code&amp;gt; || false&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spark.dynamicAllocation.minExecutors&amp;lt;/code&amp;gt; || 0&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spark.dynamicAllocation.maxExecutors&amp;lt;/code&amp;gt; || infinity&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spark.dynamicAllocation.initialExecutors&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;minExecutors&amp;lt;/code&amp;gt; (or &amp;lt;code&amp;gt;spark.executor.instances&amp;lt;/code&amp;gt; if larger)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spark.dynamicAllocation.executorAllocationRatio&amp;lt;/code&amp;gt; || 1 (request enough executors for full parallelism)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spark.dynamicAllocation.schedulerBacklogTimeout&amp;lt;/code&amp;gt; || 1s&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spark.dynamicAllocation.executorIdleTimeout&amp;lt;/code&amp;gt; || 60s&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spark.dynamicAllocation.cachedExecutorIdleTimeout&amp;lt;/code&amp;gt; || infinity&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spark.dynamicAllocation.shuffleTracking.enabled&amp;lt;/code&amp;gt; || true&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;spark.dynamicAllocation.shuffleTracking.timeout&amp;lt;/code&amp;gt; || infinity&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;small&amp;gt;Source: Spark 4.3.0 configuration reference.&amp;lt;ref name=&amp;quot;config&amp;quot; /&amp;gt;&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How is shuffle data kept when executors are removed? ==&lt;br /&gt;
During a shuffle, each executor writes its map output to local disk and serves those files to other executors. If dynamic allocation removed that executor, the files would have to be recomputed.&amp;lt;ref name=&amp;quot;jobsched&amp;quot; /&amp;gt; Spark 4.3.0 accepts four ways to avoid this; one of them must be configured with dynamic allocation:&amp;lt;ref name=&amp;quot;jobsched&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;config&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Approach !! Setting !! How it works&lt;br /&gt;
|-&lt;br /&gt;
| Shuffle tracking&lt;br /&gt;
| &amp;lt;code&amp;gt;spark.dynamicAllocation.shuffleTracking.enabled&amp;lt;/code&amp;gt; (default true, since 3.0.0)&lt;br /&gt;
| Spark keeps executors alive while they store shuffle data for active jobs, so no external service is needed&amp;lt;ref name=&amp;quot;config&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;spark27963&amp;quot;&amp;gt;{{Cite web |url=https://issues.apache.org/jira/browse/SPARK-27963 |title=SPARK-27963: Allow dynamic allocation without an external shuffle service |publisher=Apache Software Foundation JIRA |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| [[External shuffle service]]&lt;br /&gt;
| &amp;lt;code&amp;gt;spark.shuffle.service.enabled=true&amp;lt;/code&amp;gt;&lt;br /&gt;
| A long-running process on each node serves shuffle files after the executor that wrote them is gone&amp;lt;ref name=&amp;quot;jobsched&amp;quot; /&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Decommissioning with shuffle migration&lt;br /&gt;
| &amp;lt;code&amp;gt;spark.decommission.enabled&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;spark.storage.decommission.shuffleBlocks.enabled&amp;lt;/code&amp;gt;&lt;br /&gt;
| Before an executor is removed, its shuffle blocks are copied to other executors&amp;lt;ref name=&amp;quot;config&amp;quot; /&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Shuffle storage plugin&lt;br /&gt;
| &amp;lt;code&amp;gt;spark.shuffle.sort.io.plugin.class&amp;lt;/code&amp;gt; (experimental)&lt;br /&gt;
| A custom &amp;lt;code&amp;gt;ShuffleDataIO&amp;lt;/code&amp;gt; stores shuffle data in reliable storage&amp;lt;ref name=&amp;quot;config&amp;quot; /&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Shuffle tracking is the simplest because it needs no extra service. Its trade-off is that an executor holding shuffle data is not released until the shuffle is garbage collected, unless &amp;lt;code&amp;gt;spark.dynamicAllocation.shuffleTracking.timeout&amp;lt;/code&amp;gt; sets a limit.&amp;lt;ref name=&amp;quot;config&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How does dynamic allocation behave on Kubernetes? ==&lt;br /&gt;
Spark on Kubernetes does not support the external shuffle service, so &amp;lt;code&amp;gt;spark.shuffle.service.enabled=true&amp;lt;/code&amp;gt; cannot be used there.&amp;lt;ref name=&amp;quot;jobsched&amp;quot; /&amp;gt; Kubernetes deployments use shuffle tracking (on by default), decommissioning with shuffle block migration, or a shuffle storage plugin.&amp;lt;ref name=&amp;quot;jobsched&amp;quot; /&amp;gt; With &amp;lt;code&amp;gt;spark.decommission.enabled&amp;lt;/code&amp;gt;, Spark decommissions an executor instead of killing it when dynamic allocation removes it; when block manager decommissioning (&amp;lt;code&amp;gt;spark.storage.decommission.enabled&amp;lt;/code&amp;gt;) is also on, Spark tries to migrate the executor&amp;#039;s RDD and shuffle blocks to other executors first.&amp;lt;ref name=&amp;quot;config&amp;quot; /&amp;gt; &amp;lt;code&amp;gt;spark.storage.decommission.fallbackStorage.path&amp;lt;/code&amp;gt; can name a storage location, for example an S3 path, for blocks that cannot be moved to another executor; Spark does not clean it up.&amp;lt;ref name=&amp;quot;config&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On Kubernetes, &amp;lt;code&amp;gt;spark.kubernetes.dynamicAllocation.deleteGracePeriod&amp;lt;/code&amp;gt; (default 5s) is how long Spark waits for an executor pod to shut down before a forceful kill.&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; Shuffle and spill files go to &amp;lt;code&amp;gt;emptyDir&amp;lt;/code&amp;gt; volumes by default, which do not outlive the pod; persistent volume claims created on demand per executor (&amp;lt;code&amp;gt;claimName=OnDemand&amp;lt;/code&amp;gt;) are one way to give executors larger local storage when they are created dynamically.&amp;lt;ref name=&amp;quot;k8s&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Caveats ==&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Standalone mode cores.&amp;#039;&amp;#039;&amp;#039; Without &amp;lt;code&amp;gt;spark.executor.cores&amp;lt;/code&amp;gt;, each standalone executor takes all cores of a worker, and dynamic allocation can acquire many more executors than expected. The docs recommend setting cores explicitly (see SPARK-30299).&amp;lt;ref name=&amp;quot;jobsched&amp;quot; /&amp;gt;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Cached data.&amp;#039;&amp;#039;&amp;#039; Executors with cached blocks are never removed by default. With &amp;lt;code&amp;gt;spark.shuffle.service.fetch.rdd.enabled&amp;lt;/code&amp;gt;, executors that hold only disk-persisted RDD blocks can be released, and the blocks are served by the external shuffle service.&amp;lt;ref name=&amp;quot;jobsched&amp;quot; /&amp;gt;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Local checkpoints.&amp;#039;&amp;#039;&amp;#039; The Spark source warns that local checkpointing is not safe with dynamic allocation, which removes executors together with their cached blocks. See [[Checkpointing (Spark)]].&amp;lt;ref name=&amp;quot;rdd&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/core/src/main/scala/org/apache/spark/rdd/RDD.scala |title=RDD.scala (v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
spark.dynamicAllocation.enabled                  true&lt;br /&gt;
spark.dynamicAllocation.shuffleTracking.enabled  true&lt;br /&gt;
spark.dynamicAllocation.minExecutors             2&lt;br /&gt;
spark.dynamicAllocation.maxExecutors             50&lt;br /&gt;
spark.dynamicAllocation.executorIdleTimeout      120s&lt;br /&gt;
spark.executor.cores                             4&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Executor]]&lt;br /&gt;
* [[External shuffle service]]&lt;br /&gt;
* [[Push-based shuffle]]&lt;br /&gt;
* [[Shuffle]]&lt;br /&gt;
* [[Caching and persistence]]&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>