<?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_on_YARN</id>
	<title>Spark on YARN - 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_on_YARN"/>
	<link rel="alternate" type="text/html" href="https://openlakehouse.io/w/index.php?title=Spark_on_YARN&amp;action=history"/>
	<updated>2026-12-06T00:14:10Z</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_on_YARN&amp;diff=193&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_on_YARN&amp;diff=193&amp;oldid=prev"/>
		<updated>2026-11-25T00:52:55Z</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 on YARN&lt;br /&gt;
| also_known_as   = Running Spark on Hadoop YARN&lt;br /&gt;
| field           = Cluster resource management&lt;br /&gt;
| key_parts       = YARN ResourceManager, NodeManagers, containers, the Spark application master, queues&lt;br /&gt;
| implementations = [[Apache Spark]] with Apache Hadoop YARN&lt;br /&gt;
| related         = [[Spark standalone cluster manager]], [[Spark on Kubernetes]], [[Spark-submit|spark-submit]], [[Executor]]&lt;br /&gt;
}}&lt;br /&gt;
{{Verified|2026-11-23|the v4.3.0 tag of apache/spark (docs/running-on-yarn.md, docs/submitting-applications.md, docs/configuration.md, docs/job-scheduling.md, docs/cluster-overview.md, docs/core-migration-guide.md) and the Spark 0.6.0 release notes}}&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Spark on YARN&amp;#039;&amp;#039;&amp;#039; is the deployment of [[Apache Spark]] applications on Apache Hadoop YARN (Yet Another Resource Negotiator), where the YARN ResourceManager grants containers on cluster nodes and Spark runs its application master, its driver (in cluster mode) and its [[Executor|executors]] inside those containers.&amp;lt;ref name=&amp;quot;yarn&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/running-on-yarn.html |title=Running Spark on YARN (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; It lets Spark share a Hadoop cluster with other YARN workloads under the same queues and Kerberos security.&amp;lt;ref name=&amp;quot;yarn&amp;quot; /&amp;gt; YARN is one of the three cluster managers supported in Spark 4.3.0, with the [[Spark standalone cluster manager|standalone manager]] and [[Spark on Kubernetes|Kubernetes]].&amp;lt;ref name=&amp;quot;overview&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/cluster-overview.html |title=Cluster Mode Overview (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Is Spark on YARN deprecated? ==&lt;br /&gt;
No. YARN support is not deprecated in Spark 4.3.0; the cluster mode overview lists Hadoop YARN as a supported cluster manager.&amp;lt;ref name=&amp;quot;overview&amp;quot; /&amp;gt; Individual YARN settings have been deprecated: since Spark 3.5, &amp;lt;code&amp;gt;spark.yarn.max.executor.failures&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;spark.yarn.executor.failuresValidityInterval&amp;lt;/code&amp;gt; are replaced by &amp;lt;code&amp;gt;spark.executor.maxNumFailures&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;spark.executor.failuresValidityInterval&amp;lt;/code&amp;gt;.&amp;lt;ref name=&amp;quot;coremig&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;&lt;br /&gt;
&lt;br /&gt;
== History ==&lt;br /&gt;
Spark 0.6.0 added experimental support for running on YARN, then in a separate branch; the Spark documentation dates YARN support to that release.&amp;lt;ref&amp;gt;{{Cite web |url=https://spark.apache.org/releases/spark-release-0-6-0.html |title=Spark Release 0.6.0 |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;yarn&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How does Spark run on YARN? ==&lt;br /&gt;
Every Spark application on YARN has an &amp;#039;&amp;#039;&amp;#039;application master&amp;#039;&amp;#039;&amp;#039; (AM), a process managed by YARN that requests executor containers from the ResourceManager; in cluster mode the driver also runs inside it. In YARN terminology, both executors and the AM run inside &amp;#039;&amp;#039;&amp;#039;containers&amp;#039;&amp;#039;&amp;#039;.&amp;lt;ref name=&amp;quot;yarn&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Spark does not take the ResourceManager address from &amp;lt;code&amp;gt;--master&amp;lt;/code&amp;gt;. The master URL is simply &amp;lt;code&amp;gt;yarn&amp;lt;/code&amp;gt;, and Spark reads the cluster location from the Hadoop configuration directory given by &amp;lt;code&amp;gt;HADOOP_CONF_DIR&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;YARN_CONF_DIR&amp;lt;/code&amp;gt;; that configuration is also shipped to every container.&amp;lt;ref name=&amp;quot;yarn&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== What is the difference between client and cluster mode on YARN? ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! !! Cluster mode !! Client mode&lt;br /&gt;
|-&lt;br /&gt;
! Where the driver runs&lt;br /&gt;
| Inside the YARN application master container || In the client process that ran &amp;lt;code&amp;gt;spark-submit&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! Role of the AM&lt;br /&gt;
| Runs the driver and requests executors || Only requests executors&lt;br /&gt;
|-&lt;br /&gt;
! Can the client exit?&lt;br /&gt;
| Yes, after the application starts || No, the driver lives in it&lt;br /&gt;
|-&lt;br /&gt;
! AM sizing&lt;br /&gt;
| &amp;lt;code&amp;gt;spark.driver.memory&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;spark.driver.cores&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;spark.yarn.am.memory&amp;lt;/code&amp;gt; (default &amp;lt;code&amp;gt;512m&amp;lt;/code&amp;gt;), &amp;lt;code&amp;gt;spark.yarn.am.cores&amp;lt;/code&amp;gt; (default 1)&lt;br /&gt;
|-&lt;br /&gt;
! Local directories of the driver&lt;br /&gt;
| YARN&amp;#039;s &amp;lt;code&amp;gt;yarn.nodemanager.local-dirs&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;spark.local.dir&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
Source: Running Spark on YARN (Spark 4.3.0).&amp;lt;ref name=&amp;quot;yarn&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Spark documentation runs interactive shells such as &amp;lt;code&amp;gt;spark-shell&amp;lt;/code&amp;gt; in client mode, where the console stays attached to the driver. In cluster mode, local files that the driver needs must be shipped with &amp;lt;code&amp;gt;--jars&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;--files&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;--archives&amp;lt;/code&amp;gt;, because the driver runs on another machine.&amp;lt;ref name=&amp;quot;yarn&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
export HADOOP_CONF_DIR=/etc/hadoop/conf&lt;br /&gt;
./bin/spark-submit \&lt;br /&gt;
  --master yarn \&lt;br /&gt;
  --deploy-mode cluster \&lt;br /&gt;
  --queue analytics \&lt;br /&gt;
  --driver-memory 4g \&lt;br /&gt;
  --executor-memory 8g \&lt;br /&gt;
  --executor-cores 4 \&lt;br /&gt;
  --num-executors 20 \&lt;br /&gt;
  etl_job.py&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How do queues work? ==&lt;br /&gt;
YARN schedules applications into queues defined by the cluster&amp;#039;s YARN scheduler configuration. A Spark application chooses its queue with &amp;lt;code&amp;gt;--queue&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;spark.yarn.queue&amp;lt;/code&amp;gt;, which defaults to &amp;lt;code&amp;gt;default&amp;lt;/code&amp;gt;.&amp;lt;ref name=&amp;quot;yarn&amp;quot; /&amp;gt; Whether YARN honors the number of cores requested when placing containers depends on which YARN scheduler is in use and how it is configured.&amp;lt;ref name=&amp;quot;yarn&amp;quot; /&amp;gt; &amp;lt;code&amp;gt;spark.yarn.tags&amp;lt;/code&amp;gt; attaches YARN application tags that can be used to filter applications.&amp;lt;ref name=&amp;quot;yarn&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How is container memory sized? ==&lt;br /&gt;
Each executor container on YARN holds the executor heap (&amp;lt;code&amp;gt;spark.executor.memory&amp;lt;/code&amp;gt;) plus non-heap overhead (&amp;lt;code&amp;gt;spark.executor.memoryOverhead&amp;lt;/code&amp;gt;), which defaults to the executor memory times &amp;lt;code&amp;gt;spark.executor.memoryOverheadFactor&amp;lt;/code&amp;gt; with a minimum of &amp;lt;code&amp;gt;spark.executor.minMemoryOverhead&amp;lt;/code&amp;gt;. The overhead covers JVM overheads, interned strings and other native memory, and includes PySpark worker memory unless &amp;lt;code&amp;gt;spark.executor.pyspark.memory&amp;lt;/code&amp;gt; is set.&amp;lt;ref name=&amp;quot;config&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; In client mode the AM has its own overhead, &amp;lt;code&amp;gt;spark.yarn.am.memoryOverhead&amp;lt;/code&amp;gt;, which defaults to 10% of the AM memory with a minimum of 384 MiB.&amp;lt;ref name=&amp;quot;yarn&amp;quot; /&amp;gt; The [[Executor]] article covers the memory layout inside the heap.&lt;br /&gt;
&lt;br /&gt;
On YARN, &amp;lt;code&amp;gt;spark.executor.cores&amp;lt;/code&amp;gt; defaults to 1 and &amp;lt;code&amp;gt;spark.executor.instances&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;--num-executors&amp;lt;/code&amp;gt;) to 2.&amp;lt;ref name=&amp;quot;config&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;yarn&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== What still matters when running Spark on YARN? ==&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Java version.&amp;#039;&amp;#039;&amp;#039; Spark 4.0.0 and later need at least Java 17, and Hadoop supports Java 17 from 3.5.0. On a YARN cluster with an older Hadoop, the Spark documentation says to configure a separate JDK for Spark by setting &amp;lt;code&amp;gt;JAVA_HOME&amp;lt;/code&amp;gt; for the AM (&amp;lt;code&amp;gt;spark.yarn.appMasterEnv.JAVA_HOME&amp;lt;/code&amp;gt;) and executors (&amp;lt;code&amp;gt;spark.executorEnv.JAVA_HOME&amp;lt;/code&amp;gt;).&amp;lt;ref name=&amp;quot;yarn&amp;quot; /&amp;gt;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Spark JARs.&amp;#039;&amp;#039;&amp;#039; Unless &amp;lt;code&amp;gt;spark.yarn.archive&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;spark.yarn.jars&amp;lt;/code&amp;gt; points to a prepared copy, Spark zips every JAR under &amp;lt;code&amp;gt;$SPARK_HOME/jars&amp;lt;/code&amp;gt; and uploads it to the distributed cache for each application.&amp;lt;ref name=&amp;quot;yarn&amp;quot; /&amp;gt;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Hadoop classpath.&amp;#039;&amp;#039;&amp;#039; A Spark distribution built with Hadoop does not add YARN&amp;#039;s classpath to the application by default (since Spark 3.1), to avoid dependency conflicts; &amp;lt;code&amp;gt;spark.yarn.populateHadoopClasspath=true&amp;lt;/code&amp;gt; changes this.&amp;lt;ref name=&amp;quot;yarn&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;coremig&amp;quot; /&amp;gt;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Dynamic allocation and shuffle files.&amp;#039;&amp;#039;&amp;#039; To remove executors without losing their shuffle files, Spark needs an external shuffle service, shuffle tracking, shuffle block migration on decommission, or a reliable shuffle storage plugin.&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; On YARN the external shuffle service runs inside each NodeManager as the auxiliary service &amp;lt;code&amp;gt;spark_shuffle&amp;lt;/code&amp;gt;, implemented by &amp;lt;code&amp;gt;org.apache.spark.network.yarn.YarnShuffleService&amp;lt;/code&amp;gt; from the &amp;lt;code&amp;gt;spark-&amp;amp;lt;version&amp;amp;gt;-yarn-shuffle.jar&amp;lt;/code&amp;gt;.&amp;lt;ref name=&amp;quot;yarn&amp;quot; /&amp;gt;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Kerberos.&amp;#039;&amp;#039;&amp;#039; On YARN, Spark obtains delegation tokens for the default Hadoop file system and for the service that hosts the application&amp;#039;s staging directory; an application can log in to the Kerberos KDC with &amp;lt;code&amp;gt;--principal&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--keytab&amp;lt;/code&amp;gt;.&amp;lt;ref name=&amp;quot;yarn&amp;quot; /&amp;gt;&amp;lt;ref name=&amp;quot;ssargs&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/core/src/main/scala/org/apache/spark/deploy/SparkSubmitArguments.scala |title=SparkSubmitArguments.scala (v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Logs.&amp;#039;&amp;#039;&amp;#039; With YARN log aggregation (&amp;lt;code&amp;gt;yarn.log-aggregation-enable&amp;lt;/code&amp;gt;), container logs are copied to HDFS after the application ends and can be read with &amp;lt;code&amp;gt;yarn logs -applicationId &amp;amp;lt;app ID&amp;amp;gt;&amp;lt;/code&amp;gt;.&amp;lt;ref name=&amp;quot;yarn&amp;quot; /&amp;gt;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Retries.&amp;#039;&amp;#039;&amp;#039; &amp;lt;code&amp;gt;spark.yarn.maxAppAttempts&amp;lt;/code&amp;gt; sets how many times YARN attempts the application, and must not exceed YARN&amp;#039;s own &amp;lt;code&amp;gt;yarn.resourcemanager.am.max-attempts&amp;lt;/code&amp;gt;.&amp;lt;ref name=&amp;quot;yarn&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Spark-submit|spark-submit]]&lt;br /&gt;
* [[Spark on Kubernetes]]&lt;br /&gt;
* [[Spark standalone cluster manager]]&lt;br /&gt;
* [[Spark configuration precedence]]&lt;br /&gt;
* [[Executor]]&lt;br /&gt;
* [[Driver (Apache Spark)]]&lt;br /&gt;
* [[Hive on 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>