Skip to content
Gold 7 min read · spark.memory.fraction 2 practice problems ↓

The memory model

Execution vs storage memory, overhead, and what really causes spills and out-of-memory errors.

Step 2 · Spark internals · Gold · Under the hood, lesson 2 of 5

Read first: Driver, executors and the cluster manager · Caching and persistence (skip if you know them)

In plain words first

A workshop bench has a fixed size. Part of it holds tools you keep at hand (storage memory, for cachedcache: Keeping a computed DataFrame in memory (or on disk) so later actions reuse it instead of recomputing it. Learn more → data), part is free space to work on (execution memory, for joins and sorts), and the two can borrow space from each other. Some room is always taken by the bench itself (overhead). When the work does not fit, you put some of it on the floor for a while: that is a spill.

Unlock the full lesson

You have read the free part. The rest of this advanced lesson:

  • How an executor's memory is laid out
  • Execution and storage share the pool
  • Spills
  • Diagnosing out-of-memory errors
  • Rules of thumb
  • Try it yourself
  • Common mistakes
  • Key takeaways
  • Interview prep with 3 follow-up questions
  • Check yourself: 3 questions

Unlock it with the Complete pass (every advanced problem and lesson) or on its own.

Practise this

Interview problems on spark performance, graded on hidden tests

Keep going

Up next · Under the hood · lesson 3 of 5 · 8 min read
Shuffle internals
Map output files, block fetches, fetch failures and the external shuffle service.

Related lessons

Previous: Catalyst and physical plans

Primary sources: Tuning: memory management · Configuration: memory