01Driver, executors and partitions
Spark spreads a DataFrame across a cluster as partitions β chunks of rows. A driver program plans the work; executors run it. Each executor has some cores, and each core processes one partition at a time as a task.
So the basic arithmetic is:
- 1 partition β 1 task.
- Tasks run in waves of (total executor cores): waves = βpartitions Γ· coresβ.
- Stage time β waves Γ time per task.
20 partitions on 8 cores need 3 waves β and the last wave uses only 4 cores while 4 sit idle. Too few partitions leaves cores idle; far too many creates scheduling overhead. A common rule of thumb is 2β4 partitions per core.