How to Achieve Exactly-Once Processing with SQS and Lambda
A company is designing a new serverless application on AWS. The application consists of multiple AWS Lambda functions that process incoming events from an Amazon SQS queue. The company wants to ensure that each message is processed exactly once. Which configuration should the company use?
Quick Answer
The answer is to use an SQS FIFO queue with content-based deduplication enabled. This configuration is correct because FIFO queues inherently guarantee exactly-once processing by preventing duplicate message delivery through a strict first-in-first-out order and a deduplication ID that the queue uses to identify and discard any retried or resent messages within a five-minute deduplication interval. On the AWS Certified Solutions Architect Professional SAP-C02 exam, this scenario tests your understanding of how to achieve exactly-once semantics in a serverless architecture, often appearing as a trap where candidates mistakenly choose a standard SQS queue or Lambda destinations—but standard queues only offer at-least-once delivery, and Lambda destinations handle execution results, not message deduplication. A key memory tip is to think “FIFO for finality”: FIFO queues are the only SQS type that enforces exactly-once processing, making them the go-to choice when your application cannot tolerate duplicates.
⚠ Common exam trap
Many candidates assume reserved concurrency or Lambda destinations can enforce exactly-once processing, but only SQS FIFO queues with deduplication provide the necessary guarantee at the queue level.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Use an SQS FIFO queue and enable content-based deduplication.
An SQS FIFO queue guarantees first-in, first-out delivery and exactly-once processing, eliminating duplicates within a message group. Enabling content-based deduplication allows the queue to automatically detect and discard duplicate messages based on the message body, ensuring each Lambda invocation processes a unique message without additional application logic.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Use a standard SQS queue and set the Lambda function reserved concurrency to 1.
Why it's wrong here
Standard SQS queues offer at-least-once delivery, not exactly-once.
- ✓
Use an SQS FIFO queue and enable content-based deduplication.
Why this is correct
SQS FIFO queues support exactly-once processing when combined with deduplication IDs.
- ✗
Use a standard SQS queue and configure Lambda destinations for the queue.
Why it's wrong here
Lambda destinations handle async invocation results, not exactly-once processing.
- ✗
Use an SQS FIFO queue and configure DynamoDB Streams as the event source for Lambda.
Why it's wrong here
SQS FIFO can directly trigger Lambda; DynamoDB Streams are not needed.
Quick reference
Cloud Service Model Comparison
| Model | You Manage | Provider Manages | Examples |
|---|---|---|---|
| IaaS | OS, runtime, apps, data | Hardware, hypervisor, networking | EC2, Azure VMs, GCP Compute Engine |
| PaaS | Apps and data | OS, runtime, middleware, hardware | Elastic Beanstalk, Azure App Service |
| SaaS | Data and settings only | Everything else | Microsoft 365, Salesforce, Workday |
| FaaS / Serverless | Function code only | Infra, scaling, runtime | Lambda, Azure Functions, Cloud Run |
| CaaS | Containers and apps | Kubernetes, OS, hardware | EKS, AKS, GKE |
Go deeper
Related to this question
About these practice questions
One of 1,660 original SAP-C02 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
Same concept, more angles
1 more way this is tested on SAP-C02
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. A company is designing a new microservices application on AWS. The application consists of several services that need to communicate asynchronously. One service generates orders and sends them to a processing service. The order volume can vary significantly, and the processing service must scale independently. The company wants to use a managed service to decouple the services and ensure that messages are not lost. The processing service is written in Python and runs on AWS Lambda. The solutions architect needs to design the message delivery mechanism. The architect decides to use Amazon SQS. However, the Lambda function sometimes fails to process a message due to a transient error, and the message should be retried. After a maximum of three retries, the message should be moved to a dead-letter queue for analysis. Which configuration should the architect use?
medium- A.Configure the SQS DLQ with a redrive policy that allows messages to be sent back to the source queue after 3 retries.
- ✓ B.Configure the SQS queue with a visibility timeout of 6 minutes and a redrive policy with maxReceiveCount of 3, pointing to a DLQ.
- C.Configure the SQS queue with a visibility timeout of 30 seconds and a redrive policy with maxReceiveCount of 3, pointing to a DLQ.
- D.Configure Lambda with a reserved concurrency of 1 and set the SQS queue's redrive policy to maxReceiveCount of 3.
Why B: Amazon SQS supports a redrive policy on the source queue with a maxReceiveCount that determines how many times a message can be received (i.e., retried) before being moved to a dead-letter queue (DLQ). When a Lambda function processes messages from SQS, the visibility timeout acts as the retry interval: if the function fails and the message becomes visible again, it is retried. Setting maxReceiveCount to 3 and specifying a DLQ ARN meets the requirement of three retries and then moving to the DLQ. Option B is correct. Option A is incorrect because the redrive policy is configured on the source queue, not on the DLQ. The DLQ itself does not have a redrive policy to send messages back; rather, the source queue sends messages to the DLQ when the maxReceiveCount is exceeded. Also, visibility timeout is not relevant to option A. Option C is incorrect because a 30-second visibility timeout is too short; combined with three retries, it would consume retries too quickly without allowing enough time for the Lambda function to process and potentially fail, leading to premature movement to the DLQ. A 6-minute timeout (as in option B) provides sufficient time for transient errors to be resolved. Option D is incorrect because while setting the redrive policy on the SQS queue is correct, setting Lambda reserved concurrency to 1 unnecessarily throttles the function and is not required for the retry/DLQ behavior. The redrive policy alone handles the three retries and DLQ movement.
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This SAP-C02 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the SAP-C02 exam.