Scenario Q&A · Module 06c
Shuffle & Performance Tuning Q&A
Production-style questions with the answers a senior data engineer is expected to give: what the Spark UI shows,
why it happens inside the engine, and the exact config or code that fixes it. Questions tagged
from scenario notes are adapted from spark_devops_scenario_qna.md.
Most link into the Shuffle Operations Lab so you can watch the problem happen.
Quick Reference: Shuffle Configs
The knobs every answer below keeps coming back to| Config | Default | What it controls |
|---|---|---|
| spark.sql.shuffle.partitions | 200 | Reduce-side partitions after a DataFrame exchange (AQE's starting point) |
| spark.sql.adaptive.enabled | true (3.2+) | Runtime re-planning: coalesce, skew join, join switch |
| spark.sql.adaptive.advisoryPartitionSizeInBytes | 64 MB | Target size when AQE coalesces / splits |
| spark.sql.adaptive.skewJoin.skewedPartitionFactor / ThresholdInBytes | 5 / 256 MB | When a join partition counts as skewed (both must hold) |
| spark.sql.autoBroadcastJoinThreshold | 10 MB | Max estimated size of a table to broadcast automatically (-1 disables) |
| spark.sql.files.maxPartitionBytes / openCostInBytes | 128 MB / 4 MB | Read split size and per-file packing cost |
| spark.reducer.maxSizeInFlight | 48 MB | Shuffle bytes fetched concurrently per reducer |
| spark.memory.fraction | 0.6 | Heap share for execution + storage (unified memory) |
| spark.executor.memoryOverhead | max(384 MB, 10%) | Off-heap: Netty, Python workers, Arrow — common OOMKilled cause |
| spark.sql.broadcastTimeout | 300 s | How long to wait for a broadcast to be built |
Question Bank
Search, filter by topic and level, or switch on interview mode to hide answers until you've answered aloudInterview Checklist
If you can explain these with numbers, you can handle most shuffle interviews- Spark skew: spot stragglers in the Spark UI; resolve with AQE skew join, salting or broadcasting — and know AQE only splits joins.
- Partition sizing: target 100–200 MB per partition (128 MB default) — compute it from shuffle bytes.
- Read the plan: count Exchange nodes; know which operations are narrow vs wide and why partial aggregation matters.
- Sources: JDBC partitionColumn/bounds/fetchsize; splittable formats; small-file listing cost.
- Targets: tasks × partition values = files; JDBC partitions = DB sessions; MERGE rewrites files.
- Kubernetes debugging:
kubectl logs --previous, exit code 137 = OOMKilled → memoryOverhead.