DVA-C02 · Question #286
An Amazon Simple Queue Service (Amazon SQS) queue serves as an event source for an AWS Lambda function. In the SQS queue, each item corresponds to a video file that the Lambda function must convert to
The correct answer is A. Increase the memory configuration of the Lambda function.. In Lambda, memory allocation directly controls CPU power; increasing memory gives the function proportionally more CPU cycles, allowing it to process long video files faster and avoid timeouts.
Question
An Amazon Simple Queue Service (Amazon SQS) queue serves as an event source for an AWS Lambda function. In the SQS queue, each item corresponds to a video file that the Lambda function must convert to a smaller resolution. The Lambda function is timing out on longer video files, but the Lambda function's timeout is already configured to its maximum value. What should a developer do to avoid the timeouts without additional code changes?
Options
- AIncrease the memory configuration of the Lambda function.
- BIncrease the visibility timeout on the SQS queue.
- CIncrease the instance size of the host that runs the Lambda function.
- DUse multi-threading for the conversion.
How the community answered
(34 responses)- A79% (27)
- B3% (1)
- C6% (2)
- D12% (4)
Why each option
In Lambda, memory allocation directly controls CPU power; increasing memory gives the function proportionally more CPU cycles, allowing it to process long video files faster and avoid timeouts.
AWS Lambda allocates CPU proportional to the configured memory. For compute-intensive tasks like video transcoding, increasing the memory configuration increases the available CPU, which reduces processing time. Since the Lambda timeout is already at its maximum, the only way to prevent timeouts without code changes is to make the function run faster by giving it more CPU via higher memory allocation.
Increasing the SQS visibility timeout prevents a message from being redelivered to another consumer while in flight, but it does not make the Lambda function run faster or prevent it from timing out during processing.
Lambda is a managed serverless service; developers cannot choose or configure the underlying host instance size - this is controlled entirely by the memory configuration setting.
Adding multi-threading requires code changes, which the question explicitly prohibits as a solution path.
Concept tested: Lambda memory-to-CPU ratio for compute-intensive workload optimization
Source: https://docs.aws.amazon.com/lambda/latest/dg/configuration-memory.html
Community Discussion
No community discussion yet for this question.