DVA-C02 Question 6
Select 2You are developing a serverless application using AWS Lambda. Your application processes images and stores the output in an Amazon S3 bucket. Recently, you noticed that the image processing times have increased significantly during periods of high traffic. You want to optimize the application while keeping costs low. What should you do?
- A
Increase the memory allocated to the Lambda function since it also increases the available CPU power.
- B
Enable AWS X-Ray to analyze the performance bottlenecks in your Lambda function.
- C
Configure reserved concurrency for your Lambda function to handle more simultaneous executions.
- D
Implement an Amazon SQS queue to decouple the image upload process from the image processing Lambda function.
- E
Use Provisioned Concurrency for the Lambda function to reduce cold start latency during high traffic.
Show answer and explanation
Correct answers: A, D
Explanation
To optimize the Lambda function for high traffic, you should consider increasing its memory allocation to improve processing performance and implement an Amazon SQS queue to buffer and decouple incoming requests. These approaches enhance the scalability and efficiency of the application without introducing unnecessary costs or complexity.
- A. Correct.
Correct. Increasing the memory allocated to a Lambda function can improve performance because AWS allocates more CPU power proportionally to the memory setting. This can reduce processing times during high traffic.
- B. Incorrect.
Incorrect. While AWS X-Ray can help analyze performance bottlenecks, it does not directly optimize the Lambda function or reduce the processing time.
- C. Incorrect.
Incorrect. Configuring reserved concurrency limits the maximum number of simultaneous executions, which could actually throttle your function during high traffic rather than optimizing it.
- D. Correct.
Correct. Implementing an Amazon SQS queue decouples the image upload process from the Lambda function, allowing the function to process tasks asynchronously and handle spikes in traffic more effectively.
- E. Incorrect.
Incorrect. While Provisioned Concurrency is useful for reducing cold start latency, the scenario does not mention cold start issues, and it could increase costs unnecessarily.