Soru

Zorluk: OrtaMessage-Based Integration using Amazon SQS and SNS

A developer is building a high-throughput transaction ledger consumer that runs as a containerized service on Amazon ECS. The service polls messages from an Amazon SQS FIFO queue, processes the transactions, and writes the results to an external database.

The queue is configured with a default visibility timeout of 3030 seconds. Under heavy load, the database response times slow down, and processing a batch of messages can take up to 5050 seconds. Consequently, transaction records are being duplicated in the database because messages are returning to the queue before processing is complete. Additionally, the ECS task is experiencing performance degradation due to client initialization overhead.

Which of the following actions should the developer take to resolve the duplication issues and optimize client performance? (Select TWO.)

  1. Increase the default visibility timeout of the SQS queue to at least 6060 seconds to ensure messages remain invisible to other consumers until processing is completed.Cevap
  2. Instantiate the SQS client and database connection pools outside the message processing loop to reuse them across multiple execution cycles.Cevap
  3. C
    Decrease the default visibility timeout of the SQS queue to 1010 seconds to force the consumer to poll and process the messages more frequently.
  4. D
    Initialize a new instance of the AWS SDK client inside the message processing loop for every message to ensure credentials are refreshed.
  5. E
    Migrate the consumer logic to an AWS Lambda function triggered by the SQS queue, and set the Lambda function timeout to 1515 seconds.

Cevap

The correct actions are to increase the default visibility timeout of the SQS queue to at least 6060 seconds and to instantiate the SQS client outside the message processing loop.
Increasing the queue's default visibility timeout to at least 6060 seconds ensures the message remains hidden from other consumers while the 5050-second processing completes. Instantiating the client and connection pool outside the main processing loop allows the application to reuse connections across multiple message polls, avoiding CPU and network overhead.

Adım Adım Çözüm

1
Analyze the cause of message duplication.
The message processing time of 5050 seconds exceeds the visibility timeout of 3030 seconds, meaning messages return to the queue before the worker finishes processing.
This identifies the configuration parameter that must be changed to prevent concurrent duplicate deliveries.
2
Calculate and apply the correct SQS visibility timeout.
Increase the visibility timeout to at least 6060 seconds to exceed the maximum processing duration of 5050 seconds.
The visibility timeout must be set to a value greater than the maximum expected message processing time.
3
Resolve the performance degradation in the ECS container.
Move the SQS client and database pool initialization outside the message processing loop.
Reusing clients across polling iterations avoids repeated connection setup and credential retrieval overhead.

Anahtar Kavram

Configuring SQS visibility timeout based on consumer processing time and optimizing AWS SDK client reuse.
Tahmini Süre:2m 0s
Bu soruyu puanla