DVA-C02 Question 194
Single answerYou are developing a serverless application using AWS Lambda. The application needs to process large batches of messages from an Amazon SQS queue. To ensure optimal performance, you want to maximize the number of messages processed in a single invocation of the Lambda function while keeping the system scalable. Which configuration change should you make?
- A
Increase the BatchSize parameter in the event source mapping.
- B
Enable Lambda function reserved concurrency.
- C
Set the VisibilityTimeout of the SQS queue to 0 seconds.
- D
Increase the timeout value of the Lambda function to its maximum limit.
Show answer and explanation
Correct answer: A
Explanation
To optimize the processing of large batches of messages from an SQS queue, you can adjust the BatchSize parameter in the Lambda event source mapping. This parameter controls how many messages are fetched and passed to the Lambda function in a single invocation, allowing you to process more messages concurrently and reduce overall invocation costs. Other options, like reserved concurrency or increasing timeout, do not directly address batch processing efficiency.
- A. Correct.
Correct. Increasing the BatchSize parameter allows your Lambda function to process more messages in a single invocation, improving performance and reducing costs when processing large batches.
- B. Incorrect.
Incorrect. Reserved concurrency limits the number of concurrent executions of a Lambda function but does not impact the number of messages processed per invocation.
- C. Incorrect.
Incorrect. Setting the VisibilityTimeout to 0 seconds would cause unprocessed messages to become available immediately, potentially leading to duplicate processing.
- D. Incorrect.
Incorrect. Increasing the timeout value allows the Lambda function to run for longer durations but does not affect the number of messages processed in a single invocation.