Jump to content

Executor

From Open Lakehouse Wiki
Executor
Also known as Spark executor
Field Distributed data processing
Key parts Task slots (cores), execution memory, storage memory, local disk for shuffle files
Open source implementations Apache Spark
Related Shuffle, Partition, Trino, Apache Flink
Last verified 22 November 2026 against the v4.3.0 tag of apache/spark (docs/cluster-overview.md, docs/configuration.md, docs/tuning.md, docs/job-scheduling.md, docs/running-on-kubernetes.md), the Trino 484 concepts page and the Apache Flink 2.3 architecture page.

In Apache Spark, an executor is a process launched for one application on a worker node; it runs the application's tasks and keeps data in memory or on disk between them.[1] The driver plans the work and the executors do it. The same word appears in other engines with a different meaning, so this page also compares the Spark executor with a Trino worker, an Apache Flink TaskManager and a Kubernetes pod.

What an executor runs

A Spark executor runs tasks. A task is the unit of work that the driver sends to one executor, and each task processes one partition of a dataset.[1][2] Spark divides each job into stages, and every task in a stage applies the same function to a different partition.[3]

An executor runs several tasks at the same time, each in its own thread inside the executor process.[1] Besides running tasks, the executor stores cached data and writes the shuffle files that later stages read; it also serves those files to other executors unless an external shuffle service does that work.[4]

Cores and task slots

The number of tasks an executor can run at once is set by its cores. spark.executor.cores sets the cores per executor; its default is 1 on YARN and all available cores of the worker in standalone mode. spark.task.cpus (default 1) sets the cores each task needs, and the number of concurrent tasks on an executor is floor(executor cores / spark.task.cpus).[5] These concurrent places for tasks are often called task slots.

A stage with more partitions than free slots runs in waves: when a task finishes, the slot takes the next pending task. If a task fails, Spark retries it; spark.task.maxFailures (default 4) is the number of consecutive failures of one task before the job fails.[5]

Memory

Each executor is a JVM process. spark.executor.memory (default 1g) sets its heap. On YARN and Kubernetes, Spark also requests non-heap overhead memory, spark.executor.memoryOverhead, which by default is the executor memory multiplied by spark.executor.memoryOverheadFactor (0.10), with a minimum of 384 MiB. The container size is the sum of executor memory, overhead, off-heap memory and PySpark memory.[5]

Inside the heap, Spark uses a unified memory region for two purposes. Execution memory holds data for shuffles, joins, sorts and aggregations; storage memory holds cached data. spark.memory.fraction (default 0.6) sets the size of this region as a fraction of the heap minus 300 MiB, and the rest is left for user data structures and Spark metadata. Execution can evict cached blocks, but only down to the share set by spark.memory.storageFraction (default 0.5).[6] When execution data does not fit, Spark spills it to local disk.[2]

Lifetime and relation to the driver

Each Spark application gets its own executors. Without dynamic allocation they stay up for the whole application, and tasks from different applications never share a JVM. Two applications therefore cannot share in-memory data except through external storage.[1] The driver must stay reachable from the executors for its whole lifetime, and executors send heartbeats to it, by default every 10 seconds, so that it knows they are alive.[1][5]

Dynamic allocation

With dynamic resource allocation, Spark adds executors when tasks are waiting and removes executors that are idle. It is off by default (spark.dynamicAllocation.enabled) and works on standalone, YARN and Kubernetes.[4] Spark requests executors in rounds that grow exponentially (1, 2, 4, 8 and so on), and removes an executor after it has been idle for spark.dynamicAllocation.executorIdleTimeout (default 60 seconds). Executors that hold cached data are kept by default, because spark.dynamicAllocation.cachedExecutorIdleTimeout defaults to infinity.[4][5]

Removing an executor would lose the shuffle files it wrote. Dynamic allocation therefore needs one way to keep them: an external shuffle service, shuffle tracking (spark.dynamicAllocation.shuffleTracking.enabled, default true), shuffle block migration during decommissioning, or a shuffle storage plugin. Spark on Kubernetes does not support the external shuffle service.[4][5]

Spark executor compared with similar terms

Spark executor Trino worker Flink TaskManager Kubernetes pod running an executor
What it is A process started for one Spark application[1] A server in a Trino cluster that runs tasks and processes data[7] A JVM process that runs the subtasks of a dataflow and buffers and exchanges data streams[8] A Kubernetes pod that contains one executor container[9]
Coordinated by The application's driver The coordinator, which parses and plans queries[7] The JobManager[8] The Spark driver, through the Kubernetes API[9]
Unit of concurrency Task slots (executor cores divided by task CPUs) Tasks, which run drivers over splits[7] Task slots; each slot is a fixed share of managed memory, with no CPU isolation[8] Same as the executor inside it; the pod CPU request does not change task concurrency[9]
Shared between applications or queries? No; only the jobs of one application use it Yes; workers are servers of the cluster, and each query may use up to query.max-memory-per-node of user memory on a worker[7][10] In a session cluster, jobs share the cluster; in an application cluster, only one application's jobs run[8] No; the pod ends when the executor ends
Lifetime The application, or shorter with dynamic allocation The Trino cluster The Flink cluster (session) or the application (application cluster)[8] The executor; pods are cleaned up when the application completes[9]

A Flink task slot and a Spark task slot are close but not the same. A Flink slot reserves a fixed share of a TaskManager's managed memory, and by default subtasks of the same job can share a slot.[8] A Spark slot is a share of an executor's cores; all tasks on an executor draw on one unified memory pool.[6]

On Kubernetes, the pod and the executor are two layers. The pod's memory request and limit are the sum of spark.executor.memory and spark.executor.memoryOverhead, and spark.kubernetes.executor.request.cores can set the pod's CPU request apart from spark.executor.cores.[9] Shuffle and spill files go to emptyDir volumes by default, which do not outlive the pod.[9]

Example

A configuration for executors with four task slots each, scaled by dynamic allocation:

spark.executor.cores                             4
spark.executor.memory                            8g
spark.dynamicAllocation.enabled                  true
spark.dynamicAllocation.shuffleTracking.enabled  true
spark.dynamicAllocation.minExecutors             1
spark.dynamicAllocation.maxExecutors             20

See also

References

  1. ↑ 1.0 1.1 1.2 1.3 1.4 1.5 Cluster Mode Overview (Spark 4.3.0). Apache Software Foundation.Retrieved 2026-11-22.
  2. ↑ 2.0 2.1 RDD Programming Guide (Spark 4.3.0). Apache Software Foundation.Retrieved 2026-11-22.
  3. ↑ DAGScheduler.scala (v4.3.0). Apache Software Foundation.Retrieved 2026-11-22.
  4. ↑ 4.0 4.1 4.2 4.3 Job Scheduling (Spark 4.3.0). Apache Software Foundation.Retrieved 2026-11-22.
  5. ↑ 5.0 5.1 5.2 5.3 5.4 5.5 Spark Configuration (Spark 4.3.0). Apache Software Foundation.Retrieved 2026-11-22.
  6. ↑ 6.0 6.1 Tuning Spark (Spark 4.3.0). Apache Software Foundation.Retrieved 2026-11-22.
  7. ↑ 7.0 7.1 7.2 7.3 Trino concepts (Trino 484). Trino Software Foundation.Retrieved 2026-11-22.
  8. ↑ 9.0 9.1 9.2 9.3 9.4 9.5 Running Spark on Kubernetes (Spark 4.3.0). Apache Software Foundation.Retrieved 2026-11-22.
  9. ↑ Resource management properties (Trino 484). Trino Software Foundation.Retrieved 2026-11-22.