DVA-C02 Question 15
Single answerYou are developing an e-commerce application that uses AWS Lambda and Amazon API Gateway. A 'PlaceOrder' API allows users to submit their orders. To prevent duplicate order submissions due to retries caused by network issues, you decide to implement idempotency. How can you achieve this effectively?
- A
Use a unique client-generated idempotency token for each order request and store it in a database along with the order details.
- B
Enable caching in API Gateway to automatically deduplicate requests with the same payload.
- C
Implement retries with exponential backoff in the client-side code to handle network issues without the need for idempotency.
- D
Configure AWS Lambda to reject duplicate requests by default using its built-in idempotency feature.
Show answer and explanation
Correct answer: A
Explanation
Idempotency ensures that multiple identical requests have the same effect as a single request. In this scenario, using a client-generated idempotency token stored in a database allows the backend to check and reject duplicate requests. Other options, such as caching in API Gateway or client-side retries, do not directly solve the idempotency problem, and AWS Lambda does not provide a built-in idempotency feature.
- A. Correct.
Correct: Using a client-generated idempotency token, such as a UUID, ensures that even if the same request is submitted multiple times, it can be identified and processed only once by checking the token in a database.
- B. Incorrect.
Incorrect: While API Gateway caching can improve performance, it is not designed to handle idempotency for dynamic, user-specific operations like placing an order.
- C. Incorrect.
Incorrect: Implementing retries with exponential backoff on the client side is good for handling transient network issues but does not address the issue of duplicate request processing on the backend.
- D. Incorrect.
Incorrect: AWS Lambda does not have a built-in idempotency feature for rejecting duplicate requests. Idempotency needs to be handled explicitly in the application logic.