DVA-C02 Question 89
Select 2You are developing a serverless web application that uses Amazon DynamoDB as its primary database. The application allows users to view and update their account details. For the 'View Account Details' feature, it is acceptable if the data reflects eventual consistency, but for the 'Update Account Details' feature, the application should ensure the most up-to-date data is used to avoid conflicts. Which of the following approaches should you take to meet these requirements?
- A
Use eventually consistent reads for the 'View Account Details' feature and strongly consistent reads for the 'Update Account Details' feature.
- B
Use strongly consistent reads for both 'View Account Details' and 'Update Account Details' features to ensure data accuracy.
- C
Use eventually consistent reads for both 'View Account Details' and 'Update Account Details' features to optimize performance.
- D
Use eventually consistent reads for the 'View Account Details' feature and implement conditional writes for the 'Update Account Details' feature to ensure data integrity.
- E
Enable DynamoDB Streams to replay changes for both features to always retrieve the latest data.
Show answer and explanation
Correct answers: A, D
Explanation
To meet the application's requirements, you should use eventually consistent reads for 'View Account Details' to optimize performance, as it is acceptable for the data to reflect eventual consistency. For 'Update Account Details', you should ensure data integrity by either using strongly consistent reads to retrieve the latest data or using conditional writes to prevent overwrites based on outdated information. This approach strikes the right balance between performance and data accuracy.
- A. Correct.
Correct: This approach balances performance for 'View Account Details' with eventual consistency while ensuring the latest data is retrieved using strongly consistent reads for 'Update Account Details'.
- B. Incorrect.
Incorrect: While using strongly consistent reads for both features ensures accuracy, it unnecessarily sacrifices performance for the 'View Account Details' feature where eventual consistency is sufficient.
- C. Incorrect.
Incorrect: Using eventually consistent reads for both features optimizes performance but risks data conflicts for the 'Update Account Details' feature where the latest data is critical.
- D. Correct.
Correct: Eventually consistent reads for 'View Account Details' improve performance, while conditional writes ensure data integrity during updates by preventing overwrites based on outdated data.
- E. Incorrect.
Incorrect: DynamoDB Streams are used for change tracking and event-driven architectures but do not directly support read consistency or conflict resolution for these use cases.