Detecting and Fixing Data Skew
This lesson explains data skew, where a few keys hold most of the data or traffic so that a few tasks, slices, shards or partitions do most of the work, and how to detect and fix it.
Learning outcomes
After completing this lesson, you will be able to:
- Identify where skew appears in each service.
- Detect skew from task durations and metrics.
- Spread hot keys with salting.
Where skew appears
Skew means some keys carry far more data or traffic than others, and it appears in several services. In Spark, on Glue or EMR, the tasks that receive hot keys become stragglers that hold up the whole job, or run out of memory. Fixes include salting the key, adding a random suffix so its rows spread across tasks, adaptive query execution, broadcast joins for small tables, and repartitioning.
In Redshift, a distribution key with uneven values overloads some slices, so queries run as slowly as the busiest slice; a better key, or EVEN or AUTO distribution, fixes it. In Kinesis and DynamoDB, a popular partition key creates hot shards or partitions that throttle, fixed with higher-cardinality keys. The following table summarises the cases.
| Where | Effect | Fix |
|---|---|---|
| Spark (Glue, EMR) | Tasks for hot keys become stragglers or run out of memory | Salting, adaptive query execution, broadcast joins, repartitioning |
| Redshift | A skewed distribution key overloads some slices | A better distribution key, or EVEN or AUTO |
| Kinesis, DynamoDB | Hot shards and partitions throttle | Higher-cardinality partition keys |
Skew by service
Detecting skew
Data skew means that work is unevenly distributed: a few partitions or keys hold far more data than the rest, so the tasks that process them run much longer while others sit idle. Skew is usually visible in monitoring before it causes failures.
In the Spark UI, a skewed stage shows a few tasks that take far longer, or process far more data, than the median task. AWS Glue observability metrics report skew in job stages directly. In Amazon Redshift, SVV_TABLE_INFO reports row skew across slices, which slows every query on the table. In Amazon DynamoDB, CloudWatch Contributor Insights shows the most frequently accessed keys, revealing hot partitions.
The following diagram shows the task durations in a Spark stage slowed by a skewed join.

Detecting skew
Salting
Salting appends a random suffix to a hot key, so its rows spread over many partitions; results are then aggregated again without the suffix. In joins, the other side is replicated once for each suffix. Null keys, such as guest orders without a customer ID, are a frequent cause of skew and can often simply be handled separately.
The following diagram shows a hot key before and after salting.

One slow task out of a thousand
A Spark join of orders to customers finishes 999 tasks in a minute, then waits 40 minutes for the last one. The Spark UI shows that task processed 30% of all rows: orders with a NULL customer ID (guest checkouts) all hash to the same partition. The following table lists the possible fixes.
| Fix | How it helps |
|---|---|
| Filter out or handle NULL keys separately | Removes the giant group from the join |
| Salt the skewed key (append a random suffix) | Spreads one key over many partitions |
| Broadcast the smaller table | Avoids shuffling the large table at all |
| Enable adaptive query execution skew join handling | Spark splits skewed partitions automatically |
Handling guest orders separately is the simplest fix here, because they have no customer to join to.
How is skew across Redshift slices fixed?
Show answer
By changing the distribution key, or using EVEN or AUTO distribution.
Exam Tips
Remember for the exam
- Spark straggler tasks on one hot key are fixed with salting or adaptive query execution.
- Imbalanced Redshift slices are fixed by changing the distribution key, or using EVEN or AUTO.
- A hot Kinesis shard or DynamoDB partition is fixed with a higher-cardinality key.
- Broadcast the smaller table to avoid shuffling a skewed large table.
- Handle null join keys separately when they cause skew.