CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK-3-5-QUESTIONS practice question 2 of 25

A Spark DataFrame df is cached using the MEMORY_AND_DISK storage level, but the DataFrame is too large to fit entirely in memory. What is the likely…

Choose your answer, then check it against the explanation and the full breakdown below.

A Spark DataFrame df is cached using the MEMORY_AND_DISK storage level, but the DataFrame is too large to fit entirely in memory. What is the likely behavior when Spark runs out of memory to store the DataFrame?
Answer options
Question 2 of 25

Question breakdown

Tests
Understand storage level behavior for persisted DataFrames
Difficulty
Easy

Key idea: MEMORY_AND_DISK keeps as many partitions in memory as fit and writes the remaining partitions to disk, reading them back when needed.

How to reach the answer

  1. The clue is the MEMORY_AND_DISK level combined with data that is larger than available memory.
  2. This level fills memory first and puts the overflow on disk; it does not keep a full duplicate copy on disk.
  3. Spark works at partition granularity, not individual rows, and does not split data evenly or by access frequency.
  4. Processing continues, but disk reads add latency, which matches option C.

Each option

  • AIncorrect. Spark does not mirror the data in both places or move the whole DataFrame to disk; only the partitions that do not fit go to disk.
  • BIncorrect. There is no even split; memory is filled first and only the overflow goes to disk.
  • CCorrect. Partitions that fit stay in memory, the rest are spilled to disk, and the job continues with extra I/O cost.
  • DIncorrect. Placement is not driven by how often rows are accessed; storage happens at partition level as memory allows.

Common trap: Option D sounds like a smart caching policy, but Spark persistence does not track per-row access frequency; it is a simple memory-first, overflow-to-disk scheme.

In practice: When the Storage tab in the Spark UI shows a cached DataFrame split between memory and disk, expect slower reuse. Consider a serialized storage level, more executor memory, or caching only the columns you need.

Remember: MEMORY_AND_DISK means memory first, with whole partitions overflowing to disk, so the job keeps running but more slowly.

Drafted with AI assistance and checked against the answer key.

Keep practicing

Take the free CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK-3-5-QUESTIONS practice test

Ten exam-style questions with answers and explanations, plus the exam facts and study guides.

Start the free practice test

More questions

Other CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK-3-5-QUESTIONS practice questions

Scroll to Top