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 shapeTinyBalancedFat
Executors × cores60 × 112 × 52 × 30
Heap per executor6GB30GB180GB
Reserved memory, 300MB each18GB3.6GB0.6GB
Copies of the 40MB broadcast60, 2.4GB12, 480MB2, 80MB
Tasks sharing one JVM1530
Tasks rerun if one executor dies1530

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?

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.