Q19 · How do you approach hot partition problems?
Back to 24 Architecture Questions.
The question is not “rebalance harder”. The axis it turns on: whether the hotspot is a key, a tenant, or a time window. The three shapes have different causes and different fixes; the expensive mistake is applying one fix to all three, or adding nodes when the problem is that nothing spreads.
What the answer should contain
Diagnose before fixing, because the fixes are not interchangeable. A key hotspot means one item absorbs the traffic; a tenant hotspot means one customer outgrew their slice; a time-window hotspot means the current bucket takes all the writes. Monitor per-partition load and alert on skew (max/mean), because the average is exactly the number that looks fine while one partition burns.
Hot key: scatter and merge. Split the hot key into N subkeys (salted), read all N in parallel and merge, and the load spreads across partitions. Cheaper for read-hot keys: cache the celebrity, or add read-only replicas of that item. The scatter trick is for write-hot keys, where no cache saves you.
Hot tenant: isolate by tier. One large customer should not share partitions with the long tail: move them to dedicated shards, give noisy neighbors quotas, and let the tiering be explicit so the next large customer is a routing change, not an incident. The customer usually pays for their tier; make the isolation a feature.
Hot window: accept, provision, or salt. In time-partitioned data the newest bucket is always the hottest; that is normal and needs headroom, plus hot/cold tiering so old partitions stop costing. A pathological spike (a flash event landing in one minute) is salted like a hot key: write to N sub-buckets of the current window and merge on read.
Re-keying is the last resort with a plan. If the partition key itself is the defect (low cardinality, bad hash input), re-keying means a migration: dual-write or backfill, consistent hashing to limit the blast radius, and a rollback. Choose keys with the traffic shape in mind from the start: high cardinality, stable under the real query patterns.
Ideas worth mentioning out loud
- “The average partition load is a lie during a hotspot: the system has one full box and several bored ones, and scaling out buys more bored boxes.”
- Ask which celebrity it is: read-hot or write-hot. One answer is a cache, the other is an architecture change.
- Skew monitoring is cheaper than the fix: max/mean per partition, trended, catches the hotspot before the users do.
Follow-ups to expect
- Doesn’t salting break lookups by key? Reads must scatter-and-gather for that key. Salt only the keys that need it, not the whole space.
- Consistent hashing fixes this? It fixes rebalance cost, not skew: a celebrity key still lands on exactly one node no matter how you hash.
- How do you provision the hot tail for time-series? Headroom on the newest partition and automatic tiering down; the hot window is expected, not an anomaly.
Red flags in an answer
- “Add more nodes”, offered before any shape is diagnosed.
- Salting everything, including keys read by direct lookup.
- No per-partition metrics, only fleet averages.
- A re-key proposed with no migration plan and no rollback.
Sources
- Scaling DynamoDB: How partitions, hot keys, and split for heat impact performance, AWS Database Blog: key-shaped and window-shaped hotspots from the vendor whose customers hit them at the largest scale, including their own scatter strategy for hot attributes.
- Caching challenges and strategies, AWS Builders’ Library: the hot-key treatment, including the observation that the fix differs for read-hot and write-hot keys.