DVA-C02 Question 82
Single answerYou are designing a DynamoDB table to store log data for a large-scale application. The application generates millions of log entries daily and queries are primarily based on time ranges. To ensure balanced partition access and avoid hot partitions, which approach should you use for the partition key?
- A
Use a combination of a unique identifier and the timestamp as the partition key.
- B
Use a hash of the timestamp as the partition key.
- C
Use a high-cardinality attribute, such as a user ID or request ID, as the partition key.
- D
Use the raw timestamp as the partition key.
Show answer and explanation
Correct answer: A
Explanation
To achieve balanced partition access in DynamoDB, it is essential to use a high-cardinality partition key. Combining a unique identifier with the timestamp ensures that the data is evenly distributed across partitions, avoiding hot partitions and optimizing query performance. Other options either fail to address the risk of hot partitions or do not align with the nature of the queries.
- A. Correct.
Correct: Using a combination of a unique identifier (e.g., user ID or request ID) and the timestamp ensures high cardinality and distributes the data evenly across partitions, avoiding hot partitions.
- B. Incorrect.
Incorrect: Hashing the timestamp alone does not guarantee even distribution because timestamps may still cluster around specific time periods, leading to hot partitions.
- C. Incorrect.
Incorrect: Using only a high-cardinality attribute like user ID or request ID does not account for the time-based nature of the queries, potentially making it harder to query efficiently.
- D. Incorrect.
Incorrect: Using the raw timestamp as the partition key can lead to hot partitions because timestamps often cluster during peak traffic periods.