Primary Key Design Considerations - Comparing the Use of Amazon DynamoDB and Apache HBase for NoSQL

Primary Key Design Considerations

Primary key design is critical to the performance of Amazon DynamoDB. When storing data, Amazon DynamoDB divides a table's items into multiple partitions, and distributes the data primarily based on the partition key element. The provisioned throughput associated with a table is also divided evenly among the partitions with no sharing of provisioned throughput across partitions.


To efficiently use the overall provisioned throughput, spread the workload across partition key values.

For example, if a table has a very small number of heavily accessed partition key elements, possibly even a single very heavily used partition key element, traffic can become concentrated on a single partition and create "hot spots" of read and write activity within a single item collection. In extreme cases, throttling can occur if a single partition exceeds its maximum capacity.

To better accommodate uneven access patterns, Amazon DynamoDB adaptive capacity enables your application to continue reading and writing to hot partitions without being throttled, provided that traffic does not exceed your table’s total provisioned capacity or the partition maximum capacity. Adaptive capacity works by automatically and instantly increasing throughput capacity for partitions that receive more traffic.

To get the most out of Amazon DynamoDB throughput, you can build tables where the partition key element has a large number of distinct values. Ensure that values are requested fairly uniformly and as randomly as possible. The same guidance applies to global secondary indexes. Choose partitions and sort keys that provide uniform workloads to achieve the overall provisioned throughput.