The 5-Core Rule
An executor is a single JVM with a fixed number of cores and a fixed heap, and every executor in an application gets the same shape. A budget of cores and memory can be cut many ways: lots of small executors, a few large ones, or something between. The cut decides how much memory goes to fixed costs, how many copies of shared data the cluster holds, and how much in-flight work a crash throws away.
Three ways to spend 60 cores
Take a budget of 60 cores and 360GB of heap, which is 6GB per core, and a 40MB lookup table the job broadcasts after raising the broadcast threshold. Here are 3 shapes that spend the whole budget, each giving its executors 6GB of heap per core.
| Per shape | Tiny | Balanced | Fat |
|---|---|---|---|
| Executors × cores | 60 × 1 | 12 × 5 | 2 × 30 |
| Heap per executor | 6GB | 30GB | 180GB |
| Reserved memory, 300MB each | 18GB | 3.6GB | 0.6GB |
| Copies of the 40MB broadcast | 60, 2.4GB | 12, 480MB | 2, 80MB |
| Tasks sharing one JVM | 1 | 5 | 30 |
| Tasks rerun if one executor dies | 1 | 5 | 30 |
What tiny executors cost
Fixed costs are paid per executor, whatever its core count. Spark holds back 300MB of every heap as reserved memory, and every container also carries spark.executor.memoryOverhead, which by default is 10% of the heap and never less than 384MB. A broadcast table lands once in every executor, so the tiny shape stores the lookup table 60 times. Anything held in memory belongs to the JVM that holds it: a cached partition or a broadcast copy serves only the tasks running in that executor, and with 1 core per executor that is a single task.
What fat executors cost
A 30-core executor runs 30 tasks inside a single process. They share a single storage client and a single pool of network connections, and storage clients lose throughput when too many concurrent tasks read and write through them, so the extra cores wait on I/O. Garbage collection on a 180GB heap pauses all 30 tasks at once, and those pauses lengthen as the heap grows. A crash reruns 30 tasks, half of everything the cluster had in flight.
Why 5 lands in the middle
Five cores per executor sits where the 2 cost curves cross. Fixed costs split 5 ways, so reserved memory and broadcast copies fall to a fifth of the tiny shape's. Each JVM stays small enough that a crash or a pause touches only 5 tasks, and its storage client serves as many concurrent readers as it handles at full speed. Treat 5 as a starting shape: 4 or 6 behave about the same, and the rule steers you away from 1 and 30.
Cores in the same executor also compete for its execution memory. With N tasks running, Spark guarantees each task at least 1/(2N) of the execution pool and caps it at 1/N. Raising spark.executor.cores without raising spark.executor.memory shrinks every task's share, and the first symptom is spill.
A teammate proposes 4 executors of 25 cores with 150GB of heap each, 100 cores in total. Which reshaping fixes that shape's problems while keeping 100 cores and 6GB of heap per core?
- One hundred executors of 1 core and 6GB, which quiets each storage client but multiplies fixed costs and broadcast copies by 25
- Twenty executors of 5 cores and 30GB, which keeps 5 tasks per storage client and splits fixed costs across 20 JVMs
- Four executors with heaps raised to 300GB, which doubles memory per task but still leaves 25 tasks on each storage client
- Two executors of 50 cores and 300GB, which halves broadcast copies but doubles the running tasks lost to each crash
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.