Soru

Zorluk: OrtaMessage-Based Integration using Amazon SQS and SNS

A developer is implementing a background processing application on Amazon EC2 instances that retrieves and processes data batches from an Amazon SQS standard queue. Each batch processing operation takes approximately 55 minutes to complete. During testing, the developer observes that multiple EC2 instances are processing the same data batches, causing duplicate records in the database. The SQS queue is currently using the default configuration values. Which of the following actions will resolve the duplicate processing issue?

  1. Increase the visibility timeout of the SQS queue to at least 66 minutes.Cevap
  2. B
    Decrease the visibility timeout of the SQS queue to 00 seconds.
  3. C
    Redesign the application to run on AWS Lambda with a function execution timeout set to 33 minutes.
  4. D
    Hardcode an IAM user's secret access key and access key ID within the SDK client initialization code to authenticate requests faster.

Cevap

Increase the visibility timeout of the SQS queue to at least 66 minutes.
Increasing the SQS queue's visibility timeout ensures that a message remains invisible to other consumers for the entire duration of the processing logic (55 minutes). Setting the timeout to a value greater than the processing time (such as 66 minutes) allows the processing instance sufficient time to complete its task and delete the message from the queue.

Adım Adım Çözüm

1
Analyze the message lifecycle and identify the mismatch between the processing duration and the queue's default settings.
The default SQS visibility timeout is 3030 seconds, but the background job requires 55 minutes (300300 seconds) to process.
Because the processing time exceeds the visibility timeout, the message becomes visible to other consumers before the active EC2 instance can complete processing and delete it.
2
Determine the required visibility timeout duration to prevent concurrent consumption.
The visibility timeout must be set to a value greater than the maximum processing time, meaning at least 55 minutes (e.g., 66 minutes).
This guarantees that no other consumers can pull the same message from the queue during the 55-minute execution window.
3
Identify security and architectural anti-patterns in the remaining choices.
Decreasing the timeout to 00 seconds makes messages immediately visible; a 33-minute Lambda execution timeout fails the 55-minute execution requirement; and hardcoding credentials presents security risks.
These actions do not resolve the message visibility problem and introduce new operational or security failures.

Anahtar Kavram

SQS Visibility Timeout vs Consumer Processing Duration
Bu soruyu puanla