CertSafari
    Databricks Certified Associate Developer for Apache Spark· Lessons

    Domain 1 · Lesson 2/32

    Spark cluster architecture: driver, executors, cores and memory

    Identify the role of core components of Apache SparkTM's Architecture, including cluster, driver node, worker nodes/executors, CPU cores, and memory.

    15 min read
    2.86% of exam
    8 sources
    Published 21 Oct 2026
    Docs as of 17 Oct 2026

    What you will be able to do

    • Name the role of the driver, the cluster manager, worker nodes and executors in a running Spark application
    • Predict what happens to an application when its driver fails
    • Work out how many tasks a cluster can run at once from its executor cores
    • Explain why executor memory per core, rather than node count, decides whether a workload spills or runs out of memory

    Key concept

    Driver–executor division of labour — One driver process plans the application and hands out tasks. Executor processes on the worker nodes run those tasks and hold the data. Cores decide how many tasks run at once, and memory decides how much data those tasks can hold before spilling or failing.

    1.The four parts of a Spark cluster

    A Spark application is a set of processes on a cluster, and each process has one job. Your main program is the driver program. It creates the SparkContext, and the SparkContext coordinates everything else. The driver alone cannot run Spark work in parallel, so it needs help from two other parts.

    The first is the cluster manager, an external service that hands out machines and resources. Spark can use its own Standalone manager, Hadoop YARN or Kubernetes. Spark does not care which one it gets, as long as it can acquire executor processes. The second is the set of worker nodes, which are the machines that can run application code. On each worker the application launches one or more executors. An executor is a process that runs tasks and keeps data in memory or on disk between them.

    Startup follows a fixed order. The SparkContext connects to a cluster manager and Spark acquires executors on the cluster's nodes. Next it sends your application code, as JAR or Python files, to those executors. Finally the SparkContext sends tasks to the executors to run. How a job is split into those tasks is covered under the execution hierarchy.

    Cluster components and what each one does
    ComponentRole
    Driver programRuns main(), creates the SparkContext and schedules the application's tasks
    Cluster managerExternal service that acquires resources on the cluster (Standalone, YARN, Kubernetes)
    Worker nodeAny node that can run application code in the cluster
    ExecutorProcess on a worker node that runs tasks and keeps data in memory or disk storage
    TaskA unit of work sent to one executor

    Executors belong to one application. Each application gets its own executor processes, and they stay up until that application ends. This keeps applications apart: each driver schedules only its own tasks, and tasks from different applications run in different JVMs. The cost is that two applications cannot share in-memory data unless one writes it to external storage first.

    Databricks uses the same layout. A cluster there has one driver node and zero or more worker nodes, and each worker node runs exactly one executor. A cluster with zero workers can still run plain Python on the driver, but every Spark command fails because no executor exists to receive tasks. Where the driver process itself runs, inside or outside the cluster, is the subject of deploy modes.

    Checkpoint 1 of 7· Match them up

    Match each part of a Spark cluster to its role

    Tap a term, then the definition that fits it.

    Sources123

    2.What the driver does, and what happens when it fails

    Every decision about the work is made by the driver. It interprets every command, plans each query and schedules tasks on the executors. Executors never decide what to run. They wait for tasks, run them and report back. For this reason the driver must accept connections from its executors for its whole lifetime, and it must be reachable over the network from the worker nodes.

    When the driver dies, the application dies with it. The executors may still be healthy, but they have no scheduling role of their own. The cluster manager only hands out resources and does not plan stages. The executors were also launched for this application alone, so nothing else can take them over. Holding the SparkContext makes the driver a single point of coordination, and the healthy executors cannot keep the job going without it.

    A busy driver causes a quieter failure. If the driver cannot hand out tasks fast enough, the executors sit idle while you keep paying for them. In the Spark UI this shows up as long gaps in the jobs timeline. The common causes are:

    • too many streams, queries or threaded jobs running at the same time
    • non-Spark code, such as a Python loop over native functions, which runs entirely on the driver
    • many notebooks attached to the cluster, since the driver keeps state for each one

    The fix depends on the cause. A larger driver helps when the driver is overloaded with coordination work. It does nothing for a Python loop, because that code never reaches the executors. In that case, rewrite the loop with Spark DataFrames or the pandas API on Spark so the work is spread across the executors.

    Checkpoint 2 of 7· Check yourself

    In the Spark UI, the jobs timeline shows long gaps and the executors sit idle. The notebook goes through its records in a Python for-loop that calls native Python functions. Which change will keep the executors busy?

    Checkpoint 3 of 7· Exam question

    A cluster runs a single Spark application with one driver and three executors, each on a separate worker node. Partway through a long-running job, the driver process crashes due to an unrelated JVM issue on its host machine. What happens to the application?

    Sources41

    3.CPU cores are task slots

    Each core given to an executor is one task slot. Spark maps task slots to available cores one to one, and an executor runs its tasks as threads, so an executor with 4 cores runs at most 4 tasks at a time. A job is divided into smaller sets of tasks called stages, which depend on each other, and any further tasks in a stage wait for a free slot. A stage ends only when its last task finishes, so a few long-running tasks leave the other cores idle.

    The cores that count are the ones allocated to the executor, not the ones on the machine. Suppose a worker has 8 physical cores and its single executor was launched with 4. That executor runs 4 tasks at once, and the other 4 cores take no Spark tasks. Memory does not set the slot count, and the cluster manager does not reserve the extra cores for anything. They simply were not requested.

    Add up the slots and you get the cluster's parallelism. The total number of cores across all executors sets the maximum number of tasks that can run at once. Five executors with 4 cores each give 20 slots. A stage of 200 tasks then runs in about ten waves of 20, however many machines those executors sit on. How many tasks a stage has depends on partitioning.

    Slots are shared by everything running on the cluster. When several streaming queries run on one cluster, a stage from one query can fill every free slot, and the other queries have to wait. If queries need to run at the same time, the cluster needs enough cores for all of them.

    Checkpoint 4 of 7· Check yourself

    Two clusters have one executor per worker node. Cluster A has 2 workers, and each executor has 16 cores. Cluster B has 8 workers, and each executor has 4 cores. A stage has 64 tasks. How do the two clusters compare on this stage?

    Checkpoint 5 of 7· Exam question

    A team submits spark-submit --num-executors 5 --executor-cores 4 --executor-memory 16g job.py on a standalone cluster. Each worker node has 8 CPU cores and 32 GB RAM and hosts exactly one executor. A colleague asks why only 4 tasks from the current stage run at once on each executor, even though every worker has 8 cores physically available. What should you tell them?

    Sources5617

    4.Executor memory, driver memory and sizing a cluster

    Executors do the memory-heavy work. Shuffles, joins, sorts and aggregations all use executor execution memory. When that memory runs low, Spark writes data to disk, which is called spill. Spill is slower but the job keeps going. If memory runs out completely, the executor fails: Spark removes it and retries its tasks, and after repeated failures the stage and the job fail. Local disk on each node absorbs spills during shuffles and also holds cached data. Storage levels are covered under caching.

    Memory per core is what protects a task. All the tasks in an executor run as threads inside the same process and share its memory. Doubling the cores while keeping 4g doubles the number of tasks competing for that 4g, so each task gets half as much and out-of-memory errors become more likely. One way to check for a memory problem is to keep the cores and double the memory. A 4-core worker that moves from 16 GB to 32 GB has 8 GB per core instead of 4 GB. If the job then takes longer to fail, or stops failing, memory was the cause.

    Worker shapes and the memory each concurrent task gets
    Worker shapeConcurrent tasksMemory per core
    4 cores, 16 GB44 GB
    4 cores, 32 GB48 GB
    16 cores, 128 GB168 GB

    The driver's memory goes on coordination and on whatever results you bring back to it. It does not process partitions. Its memory fills up when results are pulled onto it: collect() on a large DataFrame copies the whole result set into the driver and can crash it with an out-of-memory error. When many queries share a cluster, they also share the driver's CPU, memory and schedulers. In general executors do more memory-intensive work than the driver, so the driver can stay modest unless your code makes it hold data.

    Size a cluster by its total cores and memory, not by how many nodes it has. Two workers with 16 cores and 128 GB each give the same compute and memory as eight workers with 4 cores and 32 GB each. Both have 32 slots and 256 GB. Choose between them by workload. A complex ETL job with joins across many tables does better on fewer, larger workers, because less data moves between machines during shuffles. Joins and aggregations are wide transformations: they need data from multiple partitions, so Spark shuffles it between executors. A simple ETL job that needs no wide transformations can use instances with less memory and storage. If you see heavy spill or out-of-memory errors, add memory to each instance rather than adding nodes of the same shape.

    Checkpoint 6 of 7· Check yourself

    An executor has 8 cores and 4g of memory. During a large join it keeps failing with out-of-memory errors and spilling heavily. Which change addresses the cause?

    Checkpoint 7 of 7· Exam question

    A job repeatedly fails with java.lang.OutOfMemoryError: Java heap space on the executors. The cluster has 10 worker nodes, each configured with --executor-cores 8 and --executor-memory 4g, with one executor per worker. Increasing --executor-cores to 16 without changing --executor-memory makes the failures worse. Why?

    Sources7865

    Sources

    (8)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “Each application gets its own executor processes, which stay up for the duration of the whole application and run tasks in multiple threads.”
      ↩︎ The four parts of a Spark cluster
      “An external service for acquiring resources on the cluster”
      ↩︎ The four parts of a Spark cluster
      “The driver program must listen for and accept incoming connections from its executors throughout its lifetime”
      ↩︎ What the driver does, and what happens when it fails
      “Each job gets divided into smaller sets of tasks called stages that depend on each other”
      ↩︎ CPU cores are task slots
      “A process launched for an application on a worker node, that runs tasks and keeps data in memory or disk storage across them.”
      ↩︎ Key concept
      “A process launched for an application on a worker node, that runs tasks and keeps data in memory or disk storage across them.”
      ↩︎ Checkpoint
      “Spark applications run as independent sets of processes on a cluster, coordinated by the SparkContext object in your main program (called the driver program).”
      ↩︎ Prediction
    2. 2.
      “Worker nodes run the Spark executors, one Spark executor per worker node.”
      ↩︎ The four parts of a Spark cluster
    3. 3.
      “If the compute resource has zero workers, you can run non-Spark commands on the driver node, but Spark commands will fail.”
      ↩︎ The four parts of a Spark cluster
    4. 4.
      “It interprets every command, plans each query, and schedules tasks on the executors.”
      ↩︎ What the driver does, and what happens when it fails
      “When the driver is overloaded, it can't hand out work fast enough, so the executors sit idle while you still pay for them.”
      ↩︎ What the driver does, and what happens when it fails
      “If the driver is busy running non-Spark code, a larger driver doesn't help the idle workers.”
      ↩︎ Exam trap 3
      “If the driver is busy running non-Spark code, a larger driver doesn't help the idle workers. Rewrite the code to use Spark”
      ↩︎ Checkpoint
    5. 5.
      “Spark uses a 1:1 mapping between task slots and available cores.”
      ↩︎ CPU cores are task slots
      “to avoid materializing large result sets and causing out-of-memory (OOM) errors”
      ↩︎ Executor memory, driver memory and sizing a cluster
      “In general, executors might perform more memory-intensive operations than the driver node.”
      ↩︎ Executor memory, driver memory and sizing a cluster
      “Spark uses a 1:1 mapping between task slots and available cores.”
      ↩︎ Exam trap 1
    6. 6.
      “Total executor cores (compute): The total number of cores across all executors. This determines the maximum parallelism of a compute.”
      ↩︎ CPU cores are task slots
      “Local disk is primarily used in the case of spills during shuffles and caching.”
      ↩︎ Executor memory, driver memory and sizing a cluster
      “has the same compute and memory as configuring compute with 8 workers, each with 4 cores and 32 GB of RAM.”
      ↩︎ Executor memory, driver memory and sizing a cluster
      “If you observe significant spill to disk or OOM errors, increase the amount of memory available on your instances.”
      ↩︎ Executor memory, driver memory and sizing a cluster
      “simple batch ETL jobs that don't require wide transformations, such as joins or aggregations”
      ↩︎ Executor memory, driver memory and sizing a cluster
      “processing requiring data from multiple partitions, leading to many shuffle operations”
      ↩︎ Executor memory, driver memory and sizing a cluster
      “has the same compute and memory as configuring compute with 8 workers, each with 4 cores and 32 GB of RAM.”
      ↩︎ Exam trap 4
    7. 7.
      “The other cores sit idle while those tasks finish, which results in poor cluster utilization and longer jobs.”
      ↩︎ CPU cores are task slots
      “Spill happens when Spark runs low on execution memory, which Spark uses for shuffles, joins, sorts, and aggregations.”
      ↩︎ Executor memory, driver memory and sizing a cluster
    8. 8.
      “When executors run out of memory, Spark removes them and retries their tasks.”
      ↩︎ Executor memory, driver memory and sizing a cluster
      “That gives you 8 GB per core instead of 4 GB.”
      ↩︎ Executor memory, driver memory and sizing a cluster
      “The ratio of memory to cores matters, not the total memory.”
      ↩︎ Exam trap 2

    Ready to test yourself?

    Practise Databricks Certified Associate Developer for Apache Spark in quiz mode.

    Spotted a mistake, or was something unclear? Tell us.