DVA-C02 Question 304
Single answerYou are developing a serverless application using AWS Lambda. Your function has several dependencies from third-party Python libraries. The deployment package size exceeds the maximum Lambda deployment package size limit of 50 MB when compressed. Which approach should you take to successfully deploy your Lambda function?
- A
Use AWS Lambda Layers to include your dependencies separately from the function code.
- B
Compress the deployment package further using advanced compression algorithms to reduce the size.
- C
Upload the deployment package to an S3 bucket and reference it directly in the Lambda function configuration.
- D
Split the Lambda function into smaller functions to reduce the size of individual deployment packages.
Show answer and explanation
Correct answer: A
Explanation
When the deployment package size exceeds the Lambda limit, using AWS Lambda Layers is the recommended solution. Layers allow you to package and manage dependencies separately from your function code, reducing the size of the deployment package and enabling reusability across multiple functions.
- A. Correct.
Correct. AWS Lambda Layers allow you to include external dependencies separately from your function's deployment package, helping you manage large dependencies effectively.
- B. Incorrect.
Incorrect. While compression reduces size, it is unlikely to sufficiently reduce the size beyond AWS Lambda's limits if the package already exceeds the 50 MB compressed limit.
- C. Incorrect.
Incorrect. AWS Lambda does not natively support referencing deployment packages directly from S3. The deployment package must still adhere to Lambda's size limits.
- D. Incorrect.
Incorrect. Splitting the function may not address the core issue of large dependencies. This approach also increases architectural complexity unnecessarily.