<?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=Driver_(Apache_Spark)</id>
	<title>Driver (Apache Spark) - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://openlakehouse.io/w/index.php?action=history&amp;feed=atom&amp;title=Driver_(Apache_Spark)"/>
	<link rel="alternate" type="text/html" href="https://openlakehouse.io/w/index.php?title=Driver_(Apache_Spark)&amp;action=history"/>
	<updated>2026-12-06T00:08:24Z</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=Driver_(Apache_Spark)&amp;diff=141&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=Driver_(Apache_Spark)&amp;diff=141&amp;oldid=prev"/>
		<updated>2026-11-25T00:52:39Z</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            = Driver (Apache Spark)&lt;br /&gt;
| also_known_as   = Spark driver, driver program&lt;br /&gt;
| field           = Distributed data processing&lt;br /&gt;
| key_parts       = &amp;lt;code&amp;gt;SparkContext&amp;lt;/code&amp;gt;, DAG scheduler, task scheduler, query planner, web UI (port 4040)&lt;br /&gt;
| implementations = [[Apache Spark]]&lt;br /&gt;
| related         = [[Executor]], [[SparkContext]], [[SparkSession]], [[Spark Connect]], [[Job, stage and task]]&lt;br /&gt;
}}&lt;br /&gt;
{{Verified|2026-11-23|the v4.3.0 tag of apache/spark (docs/cluster-overview.md, docs/submitting-applications.md, docs/configuration.md, docs/rdd-programming-guide.md, docs/running-on-kubernetes.md, docs/spark-connect-overview.md, python/pyspark/sql/dataframe.py, BroadcastExchangeExec.scala, QueryExecutionErrors.scala), a PySpark 4.3.0 run, and the Trino 484 concepts page}}&lt;br /&gt;
&lt;br /&gt;
In [[Apache Spark]], the &amp;#039;&amp;#039;&amp;#039;driver&amp;#039;&amp;#039;&amp;#039; is the process that runs an application&amp;#039;s &amp;lt;code&amp;gt;main()&amp;lt;/code&amp;gt; function, creates the [[SparkContext]], turns the program into tasks and schedules those tasks on [[executor]]s.&amp;lt;ref name=&amp;quot;cluster&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; Every Spark application has exactly one driver. The driver plans the work and coordinates the cluster; the executors read data, run the tasks and hold cached and shuffled data. Where the driver runs is set by the deploy mode, and its memory is a common cause of failures when results or broadcast tables are pulled back to it.&lt;br /&gt;
&lt;br /&gt;
== What runs in the driver and what runs in executors? ==&lt;br /&gt;
The Spark driver holds the application&amp;#039;s control flow. It connects to a cluster manager (standalone, YARN or Kubernetes), acquires executors, sends them the application code, and then sends them tasks to run.&amp;lt;ref name=&amp;quot;cluster&amp;quot; /&amp;gt; For DataFrame and SQL work, the driver also parses, analyzes and optimizes each query with the [[Catalyst optimizer]] and builds the physical plan. The DAG scheduler in the driver splits each job into stages and the task scheduler hands the tasks to executors.&amp;lt;ref name=&amp;quot;dag&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/core/src/main/scala/org/apache/spark/scheduler/DAGScheduler.scala |title=DAGScheduler.scala (v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; Each driver serves a web UI, typically on port 4040, that shows its jobs, stages, tasks, executors and storage.&amp;lt;ref name=&amp;quot;cluster&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Work !! Runs in the driver !! Runs in executors&lt;br /&gt;
|-&lt;br /&gt;
| Program logic outside Spark operations (loops, Python variables, &amp;lt;code&amp;gt;print&amp;lt;/code&amp;gt;) || Yes || No&lt;br /&gt;
|-&lt;br /&gt;
| Query parsing, analysis, optimization and physical planning || Yes || No&lt;br /&gt;
|-&lt;br /&gt;
| Job, stage and task scheduling; retry decisions || Yes || No&lt;br /&gt;
|-&lt;br /&gt;
| Functions passed to &amp;lt;code&amp;gt;map&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;filter&amp;lt;/code&amp;gt; and UDFs || No || Yes, inside tasks&lt;br /&gt;
|-&lt;br /&gt;
| Reading files, shuffling, joining and aggregating rows || No || Yes&lt;br /&gt;
|-&lt;br /&gt;
| Results of &amp;lt;code&amp;gt;collect()&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;take()&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;toPandas()&amp;lt;/code&amp;gt; || Received here || Computed and serialized here&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The split matters for side effects. Calling &amp;lt;code&amp;gt;rdd.foreach(println)&amp;lt;/code&amp;gt; in cluster mode prints to each executor&amp;#039;s standard output, not the driver&amp;#039;s, because the function runs inside the executors.&amp;lt;ref name=&amp;quot;rddguide&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/rdd-programming-guide.html |title=RDD Programming Guide (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The driver must stay reachable by its executors for its whole lifetime, so it has to be network addressable from the worker nodes. The Spark documentation recommends running it close to the workers, preferably on the same local network.&amp;lt;ref name=&amp;quot;cluster&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Client mode vs cluster mode ==&lt;br /&gt;
The deploy mode decides where the Spark driver process runs. In &amp;#039;&amp;#039;&amp;#039;client&amp;#039;&amp;#039;&amp;#039; mode the submitter launches the driver outside the cluster; in &amp;#039;&amp;#039;&amp;#039;cluster&amp;#039;&amp;#039;&amp;#039; mode the cluster framework launches the driver inside the cluster.&amp;lt;ref name=&amp;quot;cluster&amp;quot; /&amp;gt; &amp;lt;code&amp;gt;spark-submit --deploy-mode&amp;lt;/code&amp;gt; (or &amp;lt;code&amp;gt;spark.submit.deployMode&amp;lt;/code&amp;gt;) selects it, and the default is &amp;lt;code&amp;gt;client&amp;lt;/code&amp;gt;.&amp;lt;ref name=&amp;quot;submit&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/submitting-applications.html |title=Submitting Applications (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&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 |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;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! !! Client mode !! Cluster mode&lt;br /&gt;
|-&lt;br /&gt;
! Where the driver runs&lt;br /&gt;
| Inside the &amp;lt;code&amp;gt;spark-submit&amp;lt;/code&amp;gt; process on the submitting machine&amp;lt;ref name=&amp;quot;submit&amp;quot; /&amp;gt;&lt;br /&gt;
| On a node inside the cluster; on Kubernetes, in a driver pod&amp;lt;ref name=&amp;quot;submit&amp;quot; /&amp;gt;&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;&lt;br /&gt;
|-&lt;br /&gt;
! Console input and output&lt;br /&gt;
| Attached to the submitting console; suited to the Spark shell and other REPLs&amp;lt;ref name=&amp;quot;submit&amp;quot; /&amp;gt;&lt;br /&gt;
| Not attached; read the driver log from the cluster&lt;br /&gt;
|-&lt;br /&gt;
! Typical use&lt;br /&gt;
| A gateway machine co-located with the workers&amp;lt;ref name=&amp;quot;submit&amp;quot; /&amp;gt;&lt;br /&gt;
| Submitting from a machine far from the workers, such as a laptop, to reduce driver to executor latency&amp;lt;ref name=&amp;quot;submit&amp;quot; /&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! Setting driver memory&lt;br /&gt;
| Must be passed as &amp;lt;code&amp;gt;--driver-memory&amp;lt;/code&amp;gt; or in the defaults file, because the driver JVM has already started when &amp;lt;code&amp;gt;SparkConf&amp;lt;/code&amp;gt; is read&amp;lt;ref name=&amp;quot;config&amp;quot; /&amp;gt;&lt;br /&gt;
| &amp;lt;code&amp;gt;spark.driver.memory&amp;lt;/code&amp;gt; works as a normal setting; &amp;lt;code&amp;gt;spark.driver.cores&amp;lt;/code&amp;gt; applies only in this mode&amp;lt;ref name=&amp;quot;config&amp;quot; /&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Spark&amp;#039;s standalone cluster manager does not support cluster mode for Python applications.&amp;lt;ref name=&amp;quot;submit&amp;quot; /&amp;gt; A PySpark 4.3.0 session started without options reports &amp;lt;code&amp;gt;spark.submit.deployMode&amp;lt;/code&amp;gt; as &amp;lt;code&amp;gt;client&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Why does the driver run out of memory? ==&lt;br /&gt;
The Spark driver&amp;#039;s JVM heap is set by &amp;lt;code&amp;gt;spark.driver.memory&amp;lt;/code&amp;gt; (default &amp;lt;code&amp;gt;1g&amp;lt;/code&amp;gt;). On YARN and Kubernetes in cluster mode, &amp;lt;code&amp;gt;spark.driver.memoryOverhead&amp;lt;/code&amp;gt; adds non-heap memory, which also has to cover a Python process that goes with a PySpark driver.&amp;lt;ref name=&amp;quot;config&amp;quot; /&amp;gt; The common causes of a driver out-of-memory error all move data into this process:&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Collecting large results.&amp;#039;&amp;#039;&amp;#039; &amp;lt;code&amp;gt;collect()&amp;lt;/code&amp;gt; fetches the entire dataset to a single machine and can make the driver run out of memory; the Spark guide suggests &amp;lt;code&amp;gt;take(n)&amp;lt;/code&amp;gt; when only some rows are needed.&amp;lt;ref name=&amp;quot;rddguide&amp;quot; /&amp;gt; The PySpark API reference gives the same warning for &amp;lt;code&amp;gt;DataFrame.collect()&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;toPandas()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;toArrow()&amp;lt;/code&amp;gt;: all the data is loaded into the driver&amp;#039;s memory.&amp;lt;ref name=&amp;quot;pydf&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/python/pyspark/sql/dataframe.py |title=dataframe.py (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;Large total result size.&amp;#039;&amp;#039;&amp;#039; &amp;lt;code&amp;gt;spark.driver.maxResultSize&amp;lt;/code&amp;gt; (default &amp;lt;code&amp;gt;1g&amp;lt;/code&amp;gt;) limits the total serialized results of all partitions for one action; a job above the limit is aborted. Setting it high, or to 0 for unlimited, can lead to driver out-of-memory errors instead.&amp;lt;ref name=&amp;quot;config&amp;quot; /&amp;gt;&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Broadcast joins.&amp;#039;&amp;#039;&amp;#039; For a [[broadcast join]], Spark SQL collects the small side to the driver, builds the hash table there and then broadcasts it. If the driver runs out of memory while doing so, Spark reports that there is not enough memory to build and broadcast the table and suggests disabling broadcast with &amp;lt;code&amp;gt;spark.sql.autoBroadcastJoinThreshold=-1&amp;lt;/code&amp;gt; or raising the driver memory.&amp;lt;ref name=&amp;quot;bex&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/sql/core/src/main/scala/org/apache/spark/sql/execution/exchange/BroadcastExchangeExec.scala |title=BroadcastExchangeExec.scala (v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&amp;lt;ref name=&amp;quot;qee&amp;quot;&amp;gt;{{Cite web |url=https://github.com/apache/spark/blob/v4.3.0/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala |title=QueryExecutionErrors.scala (v4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Driver and Spark Connect ==&lt;br /&gt;
With [[Spark Connect]], the client application no longer runs in the same process as the Spark driver. The client sends unresolved logical plans to a Spark Connect server, and that server runs the driver and its &amp;lt;code&amp;gt;SparkContext&amp;lt;/code&amp;gt;. The client therefore cannot reach the driver JVM directly and has no access to the &amp;lt;code&amp;gt;SparkContext&amp;lt;/code&amp;gt; or the static Spark configuration.&amp;lt;ref name=&amp;quot;connect&amp;quot;&amp;gt;{{Cite web |url=https://spark.apache.org/docs/4.3.0/spark-connect-overview.html |title=Spark Connect Overview (Spark 4.3.0) |publisher=Apache Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt; Several Connect sessions share one server&amp;#039;s driver; state backed by the shared &amp;lt;code&amp;gt;SparkContext&amp;lt;/code&amp;gt;, such as cached datasets and global temporary views, is shared across those sessions.&amp;lt;ref name=&amp;quot;connect&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Spark driver compared with other uses of the word ==&lt;br /&gt;
The word &amp;quot;driver&amp;quot; means something different in [[Trino]], which causes confusion when reading Trino documentation next to Spark&amp;#039;s.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! !! Spark driver !! Trino driver&lt;br /&gt;
|-&lt;br /&gt;
! What it is&lt;br /&gt;
| One process per Spark application that plans and schedules all work&amp;lt;ref name=&amp;quot;cluster&amp;quot; /&amp;gt;&lt;br /&gt;
| A sequence of operator instances inside a Trino task&amp;lt;ref name=&amp;quot;trino&amp;quot;&amp;gt;{{Cite web |url=https://trino.io/docs/current/overview/concepts.html |title=Trino concepts (Trino 484) |publisher=Trino Software Foundation |access-date=2026-11-23}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! Closest counterpart in the other engine&lt;br /&gt;
| The Trino coordinator, which receives statements from clients and plans them&amp;lt;ref name=&amp;quot;trino&amp;quot; /&amp;gt;&lt;br /&gt;
| A Spark task, which runs a pipelined chain of narrow operations inside an executor&amp;lt;ref name=&amp;quot;dag&amp;quot; /&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! How many per query&lt;br /&gt;
| One for the whole application, across all its queries&lt;br /&gt;
| Many, running on the workers&amp;lt;ref name=&amp;quot;trino&amp;quot; /&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Executor]]&lt;br /&gt;
* [[SparkContext]]&lt;br /&gt;
* [[SparkSession]]&lt;br /&gt;
* [[Job, stage and task]]&lt;br /&gt;
* [[Spark Connect]]&lt;br /&gt;
* [[Broadcast join]]&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>