Scale Count Before Size

Once an executor shape works, a job that needs more capacity can get it 2 ways: more executors of that shape, or bigger executors. Reach for more executors first. The validated shape keeps its memory per core, its broadcast cost and its crash radius, and the slot count rises in step with the executor count.

What doubling the count buys

Take the 2,400-task read stage again, with tasks of 20 seconds. On 100 slots it runs 24 waves and takes 8 minutes; on 200 slots it runs 12 waves in 4 minutes. The capacity consumed stays the same: 100 slots for 8 minutes and 200 slots for 4 minutes are both 800 slot-minutes. While tasks outnumber slots, more executors buy speed at a flat cost.

Executors of 5 coresSlotsWavesStage timeSlot-minutes
10504816 min800
20100248 min800
40200124 min800
8040062 min800
16080031 min800
6003,000120 s1,000

The flat line ends when slots outnumber tasks. At 3,000 slots the stage still has 2,400 tasks, so it runs a single 20-second wave with 600 slots idle, and the run pays for all 3,000. Each stage hits this ceiling at its own task count: in a job with a 2,400-task read and a 600-task shuffle, the shuffle stage stops gaining at 600 slots, long before the read stage does. Past a stage's ceiling, only more partitions make it faster.

Why not more cores per executor

The tempting shortcut is to double spark.executor.cores from 5 to 10 on the same executors. Slots double too, but the job walks back into the fat-executor costs: 10 tasks per storage client, a heap with twice the tasks behind every pause, and twice the work rerun per crash. Unless memory doubles with it, each task's share of execution memory halves as well.

A job's slowest stage has 180 tasks of about 2 minutes each, running on 24 executors of 5 cores with no spill. What does moving to 48 executors of the same shape do to that stage?

When size is the right lever

Bigger executors help when a single task needs more memory than it gets. A task's memory comes from its own executor's unified pool, shared with the other tasks running beside it, so it depends on heap per core and never on how many executors exist. Adding 50 executors leaves every task with the memory it had. Before raising memory per core, try to shrink the task's input: more shuffle partitions, or a salted hot key. When the input can't shrink, raise spark.executor.memory with cores held at 5, or keep the heap and drop to 4 cores.

Add executors
  • The stage has more tasks than slots
  • Tasks finish without spilling
  • Many short waves make up the stage time
  • The goal is a shorter run at about the same cost
Grow each executor
  • One task spills or fails on memory
  • Its partition can't be split any further
  • A large broadcast takes much of each heap
  • Memory per task, not slot count, is the limit

A stage has 2,000 shuffle partitions of about 200MB. One task processes 9GB for a single customer ID and spills heavily while the others finish cleanly. Which change targets the problem?

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.