DVA-C02 Question 327
Single answerYou are developing a serverless application using AWS Lambda. The application processes images uploaded to an Amazon S3 bucket and stores metadata in a DynamoDB table. You notice that the Lambda function frequently exceeds the default timeout of 3 seconds. What is the BEST way to resolve this issue?
- A
Increase the timeout setting of the Lambda function.
- B
Break the processing logic into multiple smaller Lambda functions and chain them using AWS Step Functions.
- C
Enable DynamoDB Accelerator (DAX) to improve DynamoDB query performance.
- D
Upgrade the Lambda function to a provisioned Amazon EC2 instance for more processing power.
Show answer and explanation
Correct answer: B
Explanation
The best solution is to break down the processing logic into multiple smaller Lambda functions and use AWS Step Functions to orchestrate them. This approach helps avoid timeouts by distributing the workload and allows for better scalability and fault tolerance. Simply increasing the timeout or enabling DAX does not address the underlying architectural inefficiency, while moving to EC2 negates the benefits of serverless computing.
- A. Incorrect.
Increasing the timeout setting of the Lambda function might temporarily solve the issue but does not address the root cause of long processing times. A better architectural approach is required.
- B. Correct.
Breaking the logic into smaller functions and orchestrating them with AWS Step Functions is the best solution. It not only reduces the likelihood of timeouts but also improves maintainability and scalability.
- C. Incorrect.
While enabling DynamoDB Accelerator (DAX) can improve DynamoDB query performance, it will not address the long processing time caused by the Lambda function itself.
- D. Incorrect.
Moving the Lambda function to an EC2 instance increases operational overhead and reduces the benefits of serverless architecture, making it an unsuitable solution for this scenario.