What is a hot partition in DynamoDB and how can you avoid it?
Short answer
A hot partition occurs when a disproportionate amount of read or write traffic targets the same partition key, causing that specific partition to become a bottleneck even though the overall table has plenty of available capacity, and it is typically avoided by choosing a…
Advertisement
AModel answer
A hot partition occurs when a disproportionate amount of read or write traffic targets the same partition key, causing that specific partition to become a bottleneck even though the overall table has plenty of available capacity, and it is typically avoided by choosing a partition key with high cardinality, such as a user ID or a combination of attributes, rather than something with only a few possible values like a status flag.
Example
// Poor choice: partition key with low cardinality PartitionKey: OrderStatus (only a few possible values) // Better choice: high cardinality partition key PartitionKey: CustomerId
Real-world example
A ticketing platform originally partitioned its table by event ID, causing a massive hot partition during a popular concert's ticket sale, and later redesigned the key structure to spread the load more evenly across partitions.
Likely follow-ups
- How does DynamoDB adaptive capacity help mitigate hot partitions?
- What tools can you use to detect a hot partition in production?
Related topics