Apache Spark Big Data (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)
What is Data Skew in Apache Spark and how do you resolve it?
senior LevelSystem Design
In Simple Words:
Data skew occurs when one partition contains disproportionately more records than others (e.g. 90% of orders belong to country = 'US'):
- Symptom: One task in a stage runs for 45 minutes while all other 199 tasks finish in 10 seconds!
- Solutions:
- Salting: Append a random integer (e.g.
key_0tokey_9) to the join key to distribute the skewed key across 10 partitions, joining against a replicated lookup table. - Enable Adaptive Query Execution (AQE) skew join handling.
- Salting: Append a random integer (e.g.