What a Node Keeps for Itself

Executors run on nodes, and no node hands all of its hardware to Spark. These processes need CPU and memory on every machine before any executor starts:

The cluster manager offers containers only what remains after them. An executor request bigger than that remainder either stays pending or fits on fewer nodes than you planned.

The reservation and the container

This lesson plans with 1 core and 8GB held back on every 16-core, 128GB node, a common starting reservation; nodes that also run storage or monitoring daemons keep more. The cluster manager's configuration lists what it actually offers to containers, so read the numbers there instead of the hardware spec. Each container is larger than the heap inside it: it holds spark.executor.memory plus spark.executor.memoryOverhead, which defaults to 10% of the heap with a 384MB floor and covers off-heap buffers, thread stacks and, in Python jobs, the Python worker processes.

Hold back a core as well as memory. When executors claim every core, the node agent competes with a busy task on each of them for CPU time, and its heartbeats to the cluster manager can fall behind.

Fitting executors on the node

StepCoresMemory
Node hardware16128GB
Held back for OS and daemons18GB
Offered to containers15120GB
Per 5-core executor container540GB
Executor heap, container ÷ 1.1036GB
Overhead, 10% of heap3.6GB
Left unclaimed per container0.4GB

Fifteen offered cores make 3 executors of 5. The 120GB splits into 3 containers of 40GB, and since a container is its heap plus 10%, the heap can be at most 40 ÷ 1.1 ≈ 36.4GB. Round down to 36GB and the overhead is 3.6GB, leaving 0.4GB of slack in each container.

Inside each 36GB heap, Spark keeps its 300MB reserve and gives spark.memory.fraction, 0.6 by default, of the rest to the unified pool: 36GB less 0.3GB, times 0.6, is about 21.4GB. With 5 tasks running and nothing cached, each can claim up to about 4.3GB.

The same 2 divisions work on any node: offered cores ÷ 5 gives executors per node, and offered memory ÷ that count gives each container's size.

The container that doesn't fit

Ask for a 40GB heap instead and the container grows to 44GB. Three of those need 132GB, more than the 120GB on offer, so the cluster manager places 2 per node. Each node now runs 10 tasks on 15 offered cores, and a third of the capacity you pay for sits idle. A request that looked like 11% more memory per executor cost a third of the slots.

The driver takes a space too

In cluster mode the driver runs in a container on one of the worker nodes, in room an executor could have used. Give the driver a container no larger than an executor's and subtract 1 executor from the cluster's capacity. On 14 nodes that costs 1 space in 42; on 2 nodes it costs 1 in 6.

A node has 32 cores and 256GB. You hold back 2 cores and 16GB for the OS and daemons, run 5-core executors, and keep the default 10% overhead. What is the largest heap that still packs the most executors onto the node?

About this lesson

This section is part of the Cluster Sizing: Intermediate lesson on DataDriven, the home of data engineering. Lessons cover SQL, Python, Spark, data modeling and pipeline architecture, and each section pairs its explanation with worked examples and practice you run as you go.