How to Resolve Duplicate SQS Message Processing in Lambda Cost-Effectively?

A developer is creating an AWS Lambda function that consumes messages from an Amazon Simple Queue Service (Amazon SQS) standard queue. The developer notices that the Lambda function processes some messages multiple times. How should developer resolve this issue MOST cost-effectively?

  1. Change the Amazon SQS standard queue to an Amazon SQS FIFO queue by using the Amazon SQS message deduplication ID. Source Reference Answer
  2. Set up a dead-letter queue.
  3. Set the maximum concurrency limit of the AWS Lambda function to 1.
  4. Change the message processing to use Amazon Kinesis Data Streams instead of Amazon SQS.

Community Votes

A
73%
C
27%

73% of anonymous learners picked answer A. Votes are pick records left by other test-takers — they are not the verified answer.

Community Insight

This question tests the understanding of SQS standard queue at-least-once delivery semantics and how FIFO queues with deduplication IDs provide exactly-once processing without architectural changes.

When an AWS Lambda function processes Amazon SQS standard queue messages multiple times, switching to an SQS FIFO queue with a message deduplication ID is the most cost-effective solution. Community consensus strongly favors Option A because FIFO queues natively prevent duplicate delivery.

Many candidates choose Option C (setting Lambda concurrency to 1) because they confuse the duplicate processing issue with a visibility timeout problem caused by high concurrency. While limiting concurrency may reduce duplicates, it does not eliminate them and severely impacts throughput.

Community Discussion (7 comments)

BrainFried 👍 3 Selected: C
The problem is the Lambda processes the message multiple times. This is due to Lambda concurrency mixed with VisibilityTimeout of the SQS queue. VisibilityTimeout defaults to 30 seconds. Using this default, if the Lambda takes longer than 30 seconds to process the message, then the message will become available again in the Queue for consumers. This means a second Lambda can come along and dequeue the same message - leading to duplicate processing. This problem can be solved with A or C However - the question is asking for MOST cost effective The answer MUST be C then: using Lambda Reserved Concurrency (totally free).
65703c1 👍 3 Selected: A
A is the correct answer.
KarBiswa 👍 1
The actual answers are not mentioned into the options as most cost effective remedy https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html#services-sqs-batchfailurereporting:~:text=To%20prevent%20Lambda,successfully%20processes%20them.
Tchie 👍 1
B is correct Because of Cost
SerialiDr 👍 4 Selected: A
Given this, based on AWS best practices, changing the Amazon SQS standard queue to an Amazon SQS FIFO (First-In, First-Out) queue using the Amazon SQS message deduplication ID (Option A) is the most effective way to ensure messages are processed once and in the order they are sent. FIFO queues are designed to prevent duplicate processing and maintain the order of messages, which aligns with the requirement to resolve the issue of Lambda functions processing some messages multiple times.
KarBiswa 👍 1 Selected: C
In this case most cost effective option
CrescentShared 👍 4 Selected: A
A is correct.

Comments & Corrections

No comments yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

Submitted for moderation before publishing. Keep it helpful and respectful.

Expert Analysis

Understanding the Problem

Amazon SQS standard queues provide at-least-once delivery, meaning duplicate messages can occasionally be delivered due to the highly distributed nature of the system. When a Lambda function is triggered by an SQS standard queue, it may receive and process the same message more than once.

Why Option A is Correct

Option A — changing to an SQS FIFO queue with a message deduplication ID — is the most cost-effective and architecturally sound solution. FIFO queues guarantee exactly-once processing by using the MessageDeduplicationId to filter out duplicate messages within a 5-minute deduplication window. This requires no changes to the Lambda function logic and eliminates duplicates at the queue level.

Why Other Options Are Wrong

  • Option B (Dead-letter queue): A DLQ only captures messages that fail processing after a set number of retries. It does not prevent duplicate processing of successfully handled messages.
  • Option C (Maximum concurrency of 1): While reducing concurrency may lower the chance of overlapping visibility timeouts, it does not solve the fundamental at-least-once delivery nature of standard queues. It also drastically reduces throughput and is not a reliable fix.
  • Option D (Amazon Kinesis Data Streams): Migrating to Kinesis introduces significant architectural complexity and cost. It is not a cost-effective solution for a simple deduplication problem.

Community Insight

The majority of the community (73%) agrees with Option A, noting that FIFO queues are purpose-built for deduplication. The 27% who chose Option C often misattribute the duplicates to visibility timeout issues caused by concurrency, but this does not address the root cause in standard queues.

Official Reference

Exam Strategy

When an AWS exam question emphasizes 'most cost-effectively,' look for the simplest native service feature that solves the problem. Avoid answers that require major architectural rewrites (like switching to Kinesis) or that only partially mitigate the issue (like limiting concurrency).

Related Analysis

Practice All DVA-C02 Questions

Access 100 questions with complete answers and detailed explanations.

View Full DVA-C02 Practice Test →

← Back to DVA-C02 Study Guide