Simulation/Spark

Educational simulation
Spark

Driver vs Executor OOM

Rotate the cluster. Fill the wrong heap. collect(), skew, cache, and broadcast each kill a different JVM.

Driver1.2 GB / 8.0 GB

Spark 0.4 GB / 4.6 GB · user 0.5 GB / 3.1 GB

Executor 11.6 GB / 16.0 GB

Spark 0.8 GB / 9.4 GB · user 0.5 GB / 6.3 GB

Executor 21.6 GB / 16.0 GB

Spark 0.8 GB / 9.4 GB · user 0.5 GB / 6.3 GB

Executor 31.6 GB / 16.0 GB

Spark 0.8 GB / 9.4 GB · user 0.5 GB / 6.3 GB

Spark memory layout — why the exception fires

executor Spark memory = (16g − 300MB) × spark.memory.fraction 0.6 = 9.4 GB
driver Spark memory = (8g − 300MB) × 0.6 = 4.6 GB · maxResultSize = 1.0 GB

Driver heap 8.0 GB is not all yours. collect()/toPandas() still have to fit deserialized rows in that JVM. Executor Spark memory is 9.4 GB each and does not take this result.

  • Reserved 300MB
  • User 40%
  • Execution
  • Storage / cache

Code

rows = spark.table("gold.orders").collect()

Spark UI

Executors tab green. Driver stderr: Java heap space. No ExecutorLostFailure.

Fix

show() / limit() / write() — do not assemble the fact table on the driver.