Skip to main content
InterviewHubPRO
Section Overview
Q27

Question 27 of 50

Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

54%
Apache Spark Big Data (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

What are the best practices for Garbage Collection (GC) tuning in Spark?

senior LevelMemory Management

In Simple Words: Long GC pauses (> 5s) trigger heartbeat timeouts and kill executors:

  1. Use G1GC (Garbage-First Garbage Collector): -XX:+UseG1GC -XX:InitiatingHeapOccupancyPercent=35.
  2. Use DataFrames / Datasets instead of RDDs; Tungsten's off-heap binary format generates zero Java garbage collection objects!
  3. If caching large collections, use StorageLevel.MEMORY_ONLY_SER to serialize objects into byte arrays.