DVA-C02 practice question 26 of 35

A company has an application that uses an AWS Lambda function to process customer orders. The company notices that the application processes some orders more than once. A developer needs to update the application to prevent duplicate processing. Which solution will meet this requirement with the LEAST implementation effort?

Full set: 598 questions

Domain Troubleshooting and Optimization

Answer options
A: Implement a de-duplication mechanism that uses Amazon DynamoDB as the control database. Configure the Lambda function to check for the existence of a unique identifier before processing each event. Correct answer
B: Create a custom Amazon ECS task to perform idempotency checks. Use AWS Step Functions to integrate the ECS task with the Lambda function.
C: Configure the Lambda function to retry failed invocations. Implement a retry mechanism that has a fixed delay between attempts to handle duplicate events.
D: Use Amazon Athena to query processed events to identify duplicate records. Add processing logic to the Lambda function to handle the duplication scenarios that the query identifies.
Correct Answer:
A. Implement a de-duplication mechanism that uses Amazon DynamoDB as the control database. Configure the Lambda function to check for the existence of a unique identifier before processing each event.
Explanation

The most efficient and standard method to prevent duplicate processing in a Lambda function is to implement an idempotency check. Using Amazon DynamoDB as a control database is a common serverless design pattern for this purpose. The function can extract a unique identifier (e.g., orderid) from the event and attempt to write it to a DynamoDB table using a conditional expression like attributenotexists. If the write succeeds, the event is new and can be processed. If it fails because the identifier already exists, the function can safely skip processing, thus preventing duplication with minimal code and infrastructure overhead.

Why Incorrect

B. This is overly complex. Creating an ECS task and orchestrating it with Step Functions introduces significant architectural overhead and violates the "LEAST implementation effort" requirement for a simple idempotency check.
C. Retries are for handling failed invocations, not for preventing duplicate processing of distinct successful invocations. This mechanism does not address the root cause of processing an event that has already been successfully completed.
D. This is a reactive, not a preventative, solution. Using Athena to find duplicates after they have already been processed adds complexity and requires building compensation logic, rather than preventing the issue upfront.

References

1. AWS Well-Architected Framework, Serverless Applications Lens (REL 12): "To make your workload idempotent, you can use a unique request identifier. When a request is made, you can store this identifier in a persistent store, such as Amazon DynamoDB. Before you process a request, you check if the identifier exists in the store." (AWS Whitepaper, Serverless Applications Lens, Page 43).

2. AWS Lambda Powertools for Python Documentation (Idempotency Utility): "The idempotency utility provides a simple solution to convert your Lambda functions into idempotent operations... It requires a persistence layer to store the state of your function executions. The persistence layer is used to store a token for each request and prevent the execution of the same request multiple times. The utility currently supports Amazon DynamoDB as a persistence layer." (AWS Labs, AWS Lambda Powertools for Python, Idempotency section).

3. Amazon DynamoDB Developer Guide (Conditional Writes): "Amazon DynamoDB supports conditional writes for write operations (PutItem, UpdateItem, DeleteItem)... A conditional write succeeds only if the item attributes meet one or more expected conditions. Otherwise, it returns an error." This is the underlying mechanism used to atomically check for and record the unique identifier. (Amazon DynamoDB Developer Guide, Working with Items and Attributes, Conditional Writes).

Scroll to Top