The Default Resources

Leave every resource setting out of the builder and Spark still starts, using values from its documentation. Those values are small, so an application that asks for nothing can start on almost any cluster, including a busy shared one. The same small request is also what your production job receives when nobody overrides it.

SettingDefaultWhat the job gets
`spark.executor.instances`22 executors
`spark.executor.cores`11 slot in each executor, 2 in the job
`spark.executor.memory`1g1GB of heap per executor
`spark.driver.memory`1g1GB of heap for the driver

These defaults apply when executors are requested at a fixed count. In standalone mode an executor takes every free core on its worker unless spark.executor.cores is set, and local[*] on a laptop runs 1 process with a slot per CPU core.

2 slots against 1,600 tasks

Put the nightly rollup on those defaults. It reads 200GB of Parquet in 128MB partitions, so its first stage has 1,600 tasks. Suppose each task takes 20 seconds whichever executor runs it. With 2 slots, the stage completes 2 tasks every 20 seconds and needs 800 turns to get through them all. The configured session from the previous section completes 100 per turn and needs 16.

The job in this calculation never errors out. It runs, writes correct output, and finishes hours late, which is why the defaults go unnoticed: there's no error message to search for, only a stage whose progress bar barely moves.

The cluster sits idle

The slot count caps speed, whatever hardware sits behind it. Run the defaults on a cluster of 10 machines with 16 cores each and the job occupies 2 of the 160 cores; the other 158 stay free for other teams' jobs, or for nobody. Adding machines changes nothing either, since the job never asked for them.

Memory runs short too

Each default executor has a 1GB heap, and Spark keeps part of every heap for its own use before any task sees it. A task that only reads and filters passes rows through and needs little. A task that groups, joins or sorts holds rows while it works, and a 128MB Parquet partition takes more room once it is decompressed and decoded. On the defaults that task slows down or fails with an out-of-memory error, and adding executors does nothing for what 1 task can hold.

Spotting the defaults

A job reads 40GB in 128MB partitions, each task takes 30 seconds, and the session sets no resource knobs. Roughly how long does the first stage take?

About this lesson

This section is part of the Cluster Sizing: Beginner 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.