Why using a common hash key with AWS DynamoDB is a bad thing?

amazon-dynamodb, amazon-web-services, nosql

Solution

You provision writes and reads to a DynamoDB table, not a partition. Your capacity is spread/shared across the partitions, but each partition also has a fixed rate limit because of the underlying hardware.

By using a single hash key, you will have a fixed limit on how many reads and writes you can actually perform on the table, regardless of how many you are provisioning and paying for.

You can't scale it above that limit as dynamodb can't further partition your table to parallelize load processing, one of the primary ways AWS scales the system as your provision numbers increase.

It's possible you won't hit that limit at first, but Amazon recommends against this approach because Amazon wants you to use AWS in ways that will scale.

Problem

I need to have a way to have items ordered by timestamp, so I am considering using a common hash key and unix timestamp as the range key. According to the FAQ: ``` When storing data, Amazon DynamoDB divides a table into multiple partitions and distributes the data based on the hash key element of the primary key. The provisioned throughput associated with a table is also divided among the partitions; each partition's throughput is managed independently based on the quota allotted to it. There is no sharing of provisioned throughput across partitions. ``` As I am using a common hash key, then there will be no uneven load distribution - since all the load will goes into a single partition. So when I provision `100 write` to this partition, all the capacity will be used, then I suppose it is a good thing as capacity is not being wasted?

Original source