Spark Interview Question : Spark Executor Tuning Masterclass: Process 2TB Parquet Like a Pro
“Your Spark job on 2TB data is crawling at 1% done after 2 hours. The cluster looks healthy, but everything’s spilling to disk. Sound…
Spark Interview Question : Spark Executor Tuning Masterclass: Process 2TB Parquet Like a Pro

“Your Spark job on 2TB data is crawling at 1% done after 2 hours. The cluster looks healthy, but everything’s spilling to disk. Sound familiar?” 😰
If you’re sweating through massive datasets or bombing data engineering interviews, this Spark executor tuning guide is your lifeline.
That exact interview scenario — 2TB Parquet on 20 nodes (16 vCPUs, 64GB RAM each) — has crushed countless candidates.
Today, I’ll break it down so simply, you’ll calculate optimal spark-submit parameters in your sleep.
🎯 Why Spark Tuning Feels Impossible (The Real Problem)
Imagine a busy restaurant kitchen:
- Fat Chef (1 chef, all burners): Overloaded, dishes pile up
- Tiny Chefs (20 chefs, 1 pan each): Chaos, constant coordination
- Perfect (3–5 skilled chefs): Food flies out efficiently!
Your Spark cluster works the same. Without perfect — num-executors, — executor-cores, — executor-memory, your 2TB Parquet dataset becomes a nightmare:
💸 Cloud bill: $10k/month wasted
⏳ Runtime: 12 hours → 45 minutes
💥 Failures: OOM kills, disk spills everywhere
Real stakes: Netflix processes petabytes daily. One bad tuning = millions lost. Uber’s surge pricing? TB-scale Spark jobs. Interviewers at FAANG test this because 90% get it wrong.
💡 Spark Executors 101: Every Concept Explained
What Are Executors? 🏭
Think executors as worker bees in your Spark hive. Each handles:
- Tasks (smallest work unit — like reading 1 Parquet partition)
- Memory (caches data, shuffle buffers)
- Cores (parallel task threads)
Cluster (20 nodes)
↓
Executors (60 total) ← You control this!
↓
Tasks (16,000+) ← Spark auto-creates
The 3 Golden Parameters (Your Control Knobs)
1. --num-executors = "How many worker bees?"
→ More = better parallelism (but overhead)
2. --executor-cores = "CPUs per bee"
→ 1-2 = too little CPU
→ 10+ = thread fights (contention)
3. --executor-memory = "RAM per bee"
→ Too little = disk spill
→ Too much = garbage collection hell
The FAT EXECUTOR Trap (Why Everything Breaks) 😈
WRONG ❌ --num-executors 20, --executor-cores 15, --executor-memory 60g
= 1 fat executor PER NODE!
Problems:
🔥 Single point failure = entire node dead
🐌 HDFS can't feed 15 tasks fast enough
🗑️ 60GB garbage collection pauses (30s+)
Analogy: Like hiring one bodybuilder to lift 100 boxes alone vs. 5 fit guys working together.
🧪 Step-by-Step Math: Your 2TB Scenario (Whiteboard Style)
Given:
No of nodes = 20
Each Node Capacity : (16 vCPUs, 64GB RAM)
Process : 2TB Parquet
Optimal Sizing Rules :
Reserve 1 core + 1GB per node for OS/YARN process.
Cores: Total available cores / 5 (industry sweet spot).
Executors per node: Available cores / executor-cores (aim 2-5/node).
Memory: Available RAM / executors-per-node * 90% ( 10% reserved for overhead).
For your cluster: 20 nodes × (15 cores, 63GB avail)
STEP 1: Calculate AVAILABLE resources (RESERVE for OS/YARN!)
Cores/node: 16 - 1 = 15
RAM/node: 64 - 1 = 63GB
Total cores: 20(nodes) × 15 = 300
Total RAM: 20 × 63 = 1,260GB
STEP 2: Perfect executor-cores = 5 (industry gold standard)
Why 5?
- 4-6 cores = sweet spot (minimal thread contention)
- Each handles ~128MB Parquet partitions perfectly
- Good for CPU + I/O balance
STEP 3: Executors per node = 15 cores ÷ 5 = 3 executors/node
Total --num-executors = 20 × 3 = 60 executors!
or
We can also calculate from
Total no of cores = 300
No of cores in 1 executor = 5 (from above)
Total --num-executors = 300 / 5 = 60 🎉
STEP 4: Memory calculation
RAM per executor = 63GB ÷ 3 executors = 21GB raw
Spark usable = 21GB × 90% = 18.9GB (as 10% memory goes to overhead)
→ --executor-memory 18g (safe rounding)
🎯 YOUR PERFECT COMMAND:
spark-submit \
--num-executors 60 \
--executor-cores 5 \
--executor-memory 18g \
--executor-memoryOverhead 3g \
--driver-memory 4g \
your_etl_job.py
Why this wins:
- 300 total cores = 100% cluster utilization
- 16,000 partitions ÷ 300 cores = 53 partitions/core (3 waves)
- 2 TB scan completes in ~15 minutes vs 6+ hours!
🧪 Real Code Example: See It Work
# process_2tb_parquet.py
from pyspark.sql import SparkSession
spark = SparkSession.builder \
.appName("2TB_Parquet_Processor") \
.config("spark.sql.files.maxPartitionBytes", "128MB") \
.getOrCreate()
# Your 2TB dataset
df = spark.read.parquet("s3://your-bucket/2tb-data/")
print(f"Partitions: {df.rdd.getNumPartitions()}") # ~16,000
# Simple aggregation (real ETL)
result = df.groupBy("category").count()
result.write.mode("overwrite").parquet("s3://output/")
spark.stop()
Expected Spark UI (after perfect tuning):
✅ Executor memory fraction: 75% (perfect)
✅ GC time: <1% (blazing)
✅ Tasks/sec: 1000+
✅ Shuffle read/write: Minimal
⚠️ 5 Deadly Beginner Mistakes (And Fixes)
❌ MISTAKE 1: "1 executor per node" (Fat Trap)
Fix: Always 2-5 executors/node
❌ MISTAKE 2: executor-cores=1 (Tiny executors)
Fix: 4-6 cores minimum
❌ MISTAKE 3: No memoryOverhead
Fix: Add --executor-memoryOverhead=2-4g
❌ MISTAKE 4: driver-memory=1g (bottleneck)
Fix: driver-memory=4-8g for collect()
❌ MISTAKE 5: Forgetting OS reserves
Fix: -1 core, -1GB per node ALWAYS
🚀 7 Pro Tips (Production-Grade)
- Enable AQE (Spark 3+):
spark.sql.adaptive.enabled=true - Monitor Spark UI → Target: <5s tasks, <1% GC
- Parquet partitioning:
spark.sql.files.maxPartitionBytes=128MB - Dynamic allocation: Auto-scale executors
- Test pattern: 10% data → 100% data → production
- YARN formula: Total executors = (cores × nodes × 0.94) / cores_per_executor
- Databricks trick: Let autoscaling handle it (but know manual!)
📌 Lets Recap
- Cluster: 20 × (16c / 64G) → 300 cores, 1260GB available
- Magic numbers:
--num-executors 60 --executor-cores 5 --executor-memory 18g - Why: 100% utilization, 3 waves of 16k partitions
- Avoid: Fat executors (1/node), no overhead, wrong reserves
💡 MANTRA: "Reserve 1c/1G, 5 cores/executor, 3 execs/node"
If you are looking to move beyond default configurations and optimize your Spark jobs for massive datasets, these three articles are must-reads :
- Processing 10TB in 10 Minutes (Performance focus): https://medium.com/cub3d/processing-10-tb-data-in-apache-spark-in-10-minutes-how-to-choose-spark-submit-parameters-900d3506937f
- Executor Tuning Masterclass (Interview focus): https://medium.com/@sriwworldofcoding/spark-interview-question-spark-executor-tuning-masterclass-process-2tb-parquet-like-a-pro-6fa0428b1237
- Cost-Effective Tuning Guide (ROI focus): https://medium.com/towards-data-engineering/processing-10-tb-data-in-apache-spark-in-3-hours-a-cost-effective-tuning-guide-5e52908c98fb
These resources are perfect for anyone preparing for Data Engineering interviews or managing production-level Big Data pipelines. Check them out! 💡
🚀 Level Up Your Career — Don’t Wait, Start NOW!
If you’re serious about growing in tech and staying ahead of the curve, this is your moment. No shortcuts — just real skills that actually make a difference.
🌐 Let’s Connect & Grow Together
Follow me for practical insights, real-world learning, and career tips:
🐦 Twitter: https://x.com/SriwWorld 📺 YouTube: https://www.youtube.com/@sriwworldofcoding?sub_confirmation=1 ✍️ Medium: https://medium.com/@sriwworldofcoding 🧵 Threads: https://www.threads.com/@sriwworldofcoding 📸 Instagram: https://www.instagram.com/sriwworldofcoding/ 📘 Facebook: https://www.facebook.com/profile.php?id=61576419014220 🌌 Bluesky: https://bsky.app/profile/sriwworldofcoding.bsky.social
🎯 Want Real Skills? Start With These Hands-On Courses
⚙️ Apache Airflow Bootcamp (Workflow Automation)
👉 https://www.udemy.com/course/apache-airflow-bootcamp-hands-on-workflow-automation/ 💡 Go from beginner to advanced — master DAGs, scheduling, operators, sensors, and build real production workflows.
🔥 PySpark for Data Engineers (Architecture + Interviews)
👉 https://www.udemy.com/course/pyspark-for-data-engineers-architecture-interviews/ 💡 Deep dive into Spark architecture, optimization, and performance tuning — plus crack interviews with confidence.
☁️ Crack Azure Data Engineer Interviews: The Ultimate Q&A Guide
👉 https://www.udemy.com/course/crack-azure-data-engineer-interviews-the-ultimate-qa-guide/ 💡 Get interview-ready with real-world questions on ADF, Synapse, Databricks, Event Hubs, Data Lake, Azure Functions & more.
💥 The difference between where you are and where you want to be? ACTION. Start learning today — your future self will thank you.
메타데이터
- post_id
- 6fa0428b1237
- slug
- spark-interview-question-spark-executor-tuning-masterclass-process-2tb-parquet-like-a-pro-6fa0428b1237
- url
- https://medium.com/towards-data-engineering/spark-interview-question-spark-executor-tuning-masterclass-process-2tb-parquet-like-a-pro-6fa0428b1237
- canonical_url
- https://medium.com/towards-data-engineering/spark-interview-question-spark-executor-tuning-masterclass-process-2tb-parquet-like-a-pro-6fa0428b1237
- author_url
- https://medium.com/@sriwworldofcoding
- status
- ok
- fetched_at
- 2026-08-05 21:16:17