Options: A) Increase spark.executor.memory B) Remove the groupBy operation C) Set spark.sql.shuffle.partitions to 1 D) Disable Spark caching
medium
A. Remove the groupBy operation
B. Increase spark.executor.memory
C. Set spark.sql.shuffle.partitions to 1
D. Disable Spark caching
Solution
Step 1: Identify cause of out-of-memory error
GroupBy with aggregation can cause large shuffle and memory use.
Step 2: Choose optimization to prevent failure
Increasing executor memory allows Spark to handle larger shuffle data without failure.
Final Answer:
Increase spark.executor.memory -> Option B
Quick Check:
More memory = fewer out-of-memory errors [OK]
Hint: More memory helps with heavy aggregations [OK]
Common Mistakes:
Removing groupBy loses needed aggregation
Setting partitions to 1 can cause slow jobs, not fix memory
Disabling caching unrelated to memory errors here
5. You want to optimize a Spark job that processes a large dataset with many small files causing job failures. Which combined approach best prevents failures?
Options: A) Increase spark.executor.memory and coalesce files before processing B) Decrease spark.sql.shuffle.partitions and disable Spark dynamic allocation C) Remove caching and increase driver memory D) Increase shuffle partitions and reduce executor cores
hard
A. Increase spark.executor.memory and coalesce files before processing
B. Decrease spark.sql.shuffle.partitions and disable Spark dynamic allocation
C. Remove caching and increase driver memory
D. Increase shuffle partitions and reduce executor cores
Solution
Step 1: Understand problem with many small files
Many small files cause overhead and memory pressure during processing.