DVA-C02 exam dumps

DVA-C02 practice question 81 of 399

AWS Certified Developer - Associate. Associate level, Amazon Web Services. Free question with the correct answer and a full explanation.

DVA-C02 Question 81

Single answer

You are designing a DynamoDB table to store user activity logs for a web application. Each log entry includes a userId, activityType, and timestamp. The table will experience high write throughput, and queries will often retrieve logs for a specific user in a specific time range. How can you design the partition key to ensure balanced partition access and avoid hot partitions?

  1. A

    Use userId as the partition key and timestamp as the sort key.

  2. B

    Use a composite key by concatenating userId with a hashed value of timestamp as the partition key, and use timestamp as the sort key.

  3. C

    Use activityType as the partition key and timestamp as the sort key.

  4. D

    Use a random UUID as the partition key and timestamp as the sort key.

Show answer and explanation

Correct answer: B

Explanation

To achieve balanced partition access, the partition key should be designed to distribute data evenly across all partitions, avoiding hot partitions. By concatenating userId with a hashed value of timestamp, you ensure that data for each user is distributed across multiple partitions, balancing the workload. Using timestamp as the sort key enables efficient range queries for specific time intervals.

  • A. Incorrect.

    Using userId as the partition key and timestamp as the sort key can lead to hot partitions if certain users generate significantly more activity than others. This design won't distribute traffic evenly.

  • B. Correct.

    Using a composite key by concatenating userId with a hashed value of timestamp as the partition key ensures better distribution of write and read requests across partitions, minimizing the risk of hot partitions. The timestamp as the sort key allows efficient querying within specific time ranges.

  • C. Incorrect.

    Using activityType as the partition key and timestamp as the sort key is not appropriate for this use case because queries often focus on specific users, and this design would not align well with the access patterns.

  • D. Incorrect.

    Using a random UUID as the partition key would distribute traffic but makes it impossible to query logs for a specific user efficiently, as the partition key would have no relationship to userId.

Timed practice exam

Take a DVA-C02 practice test under exam conditions

65 questions in 130 minutes, drawn from this bank, with a score report and a per-question review when you finish.

Start timed exam