One task takes 40 minutes while 199 tasks take 2 minutes
Symptoms
- Stage duration dominated by a single task
- Cluster CPU mostly idle near the end of the stage
Likely cause
Data skew on a shuffle key
How to investigate
- Open Spark UI → Stages → identify longest task
- Compare input size and shuffle read per task
- Check key cardinality for the join/groupBy key
Spark UI evidence
- Task duration histogram with a long tail
- One partition far larger than others
Possible solutions
- Salt skewed keys
- Enable AQE skew join handling
- Broadcast the smaller side when possible
Tradeoffs
- Salting increases shuffle write volume
- Broadcast requires enough executor memory