In an AWS Lambda handler, you need to ensure idempotency when processing duplicate SQS messages. Which approach best prevents double-processing of a task when at-least-once delivery occurs?
Answer
Write the handler so it always overwrites the same item in DynamoDB using a deterministic partition/sort key derived from the messageId
Explanation
At-least-once delivery means duplicates can occur; using deterministic keys with an upsert pattern (and often conditional writes) allows safe repeat processing. Reserved concurrency and FIFO ordering do not by themselves guarantee idempotency across retries or duplicate deliveries.
Last reviewed: October 2026
Reviewed by FirstInTest Editorial Team
Related questions
You must implement a secure webhook receiver behind API Gateway that validates an HMAC signature on each request and stores events for later processing. Which design best ensures integrity, replay protection, and eventual processing?
View question →
A Lambda function publishes events to EventBridge, and other services consume them through rules. You must ensure that consumers can reconstruct order of events per aggregate and avoid missed events after deployment. What is the best practice?
View question →
A developer uses Lambda with a custom runtime and wants to stream logs to CloudWatch with minimal overhead. They also must ensure the function can correlate logs to a specific user request across retries. What is the best strategy?
View question →
A service receives events from a queue, writes transformed records to DynamoDB, and then notifies downstream systems via an EventBridge PutEvents call. During a deployment, some messages are retried and you observe occasional duplicates in DynamoDB. Which change most effectively eliminates duplicates without relying on exactly-once delivery?
View question →
You are designing a service that receives API Gateway requests and calls downstream services. The downstream service can sometimes be slow or fail transiently. Which combination most appropriately applies the AWS SDK and API behavior to protect latency and improve reliability?
View question →
A DynamoDB table is used to store user sessions with a TTL attribute. During testing, some expired sessions still appear when queried by partition key. What is the most accurate explanation and recommended handling?
View question →