AWS Certified Developer – Associate / Question #583 of 557

Question #583

A developer is building an order processing system deployed on AWS Lambda. Each order is assigned a unique identifier, and the system may experience sudden spikes in order requests at any time. During throttling events, the system might retry requests. The system must ensure that each order is processed exactly once, even if duplicate requests are sent. Which solution will meet these requirements?

A

Create an Amazon RDS for PostgreSQL DB instance. Store the unique order identifier in a database table. Configure the Lambda function to query the table for the identifier before processing the order.

B

Create an Amazon DynamoDB table. Store the unique order identifier in the table. Configure the Lambda function to check the table for the identifier before processing the order.

C

Create an Amazon DynamoDB table. Store the unique order identifier in the table. Modify the Lambda function to return an error response if a duplicate order identifier is detected.

D

Create an Amazon ElastiCache for Redis cluster. Store the unique order identifier in the cache. Configure the Lambda function to check the cache for the identifier before processing the order.

Explanation

Answer B is correct because:
- DynamoDB's Scalability: DynamoDB automatically scales to handle sudden traffic spikes, critical for Lambda-based systems with unpredictable loads.
- Idempotency Check: Storing unique order IDs in DynamoDB allows the Lambda function to check for existing entries before processing, ensuring no duplicates.
- Atomic Operations: DynamoDB supports conditional writes, enabling thread-safe checks without race conditions.

Why other options fail:
- A (RDS PostgreSQL): Relational databases struggle with high write throughput and scalability during traffic spikes, creating bottlenecks.
- C (DynamoDB with Error Response): Returning errors on duplicates does not ensure the order is processed; retries might fail permanently.
- D (ElastiCache Redis): In-memory caches lack durability; data loss during failures could lead to duplicate processing.

Key Points:
- Use DynamoDB for scalable, serverless idempotency checks.
- Ensure atomicity and durability to prevent duplicates.
- Avoid solutions that cannot handle high concurrency or lack persistence.

Answer

The correct answer is: B