Home › Forums › AWS › AWS Certified Solutions Architect Associate › The importance of partition keys in DynamoDB tables
-
The importance of partition keys in DynamoDB tables
theodosiostziomakas updated 3 months, 1 week ago 2 Members · 3 Posts -
Hello everyone,
So there is an exam question from the first timed test
Docker application, which is running on an Amazon ECS cluster behind a load balancer, is heavily using DynamoDB. You are instructed to improve the database performance by distributing the workload evenly and using the provisioned throughput efficiently.
Which of the following would you consider to implement for your DynamoDB table?
A) Reduce the number of partition keys in the DynamoDB table.
B) Use partition keys with high-cardinality attributes, which have a large number of distinct values for each item.
C) Use partition keys with low-cardinality attributes, which have a few number of distinct values for each item.
D) Avoid using a composite primary key, which is composed of a partition key and a sort key.
I don’t understand why the correct answer is B.
Many thanks,
Theodosios
-
Hello Theo,
Thank you for your feedback! Let me clarify why the correct answer is “Use partition keys with high-cardinality attributes, which have a large number of distinct values for each item.”
In the scenario, you’re tasked with improving the performance of a DynamoDB table by distributing the workload evenly and using provisioned throughput. DynamoDB uses partition keys to split data across multiple partitions. For optimal performance, it’s important that the partition keys have high-cardinality, meaning they have many unique values.
High-cardinality attributes (like unique customer IDs or order numbers) ensure that DynamoDB can spread data and traffic evenly across its partitions, preventing any single partition from being overwhelmed. This directly addresses the requirement to “distribute the workload evenly.”
On the other hand, low-cardinality attributes (like a simple status flag with only a few values such as “active” or “inactive”) would lead to uneven distribution of traffic, overloading certain partitions and making the database less efficient.
Hence, Option B is the best way to distribute the workload and improve database performance efficiently.
I hope this helps! Please feel free to ask if you need further clarification.
Regards,
Nikee @ Tutorials Dojo
-
Thank you Nikee,
It’s all clear now.
Regards,
Theo
Log in to reply.