A data science team has a Python Lambda function whose dependencies (NumPy, SciPy and a compiled model library) total about 1.4 GB when unzipped, so the .zip deployment fails.
The function must not be attached to a VPC, and the team wants the dependencies delivered with the function, not fetched over the network during cold starts.
What should the developer do?
Choose one answer.
AA. Build a container image with the code and dependencies, push it to Amazon ECR, and create the function from the image.
BB. Split the dependencies across the maximum number of Lambda layers and attach all of them to the function for more room.
CC. Upload the .zip to Amazon S3 and create the function from the S3 object, which removes the package size limit.
DD. Place the dependencies on an Amazon EFS file system mounted under /mnt/libs, and load them from there at cold start.
Show the answer and explanation
Answer: A
A. Right: Correct. A container image function can be up to 10 GB uncompressed, including its layers, which is enough for these libraries. The dependencies ship inside the image, and no VPC is needed. Learn more: Lambda container images (opens in a new tab)
B. Wrong: A function can use at most five layers, and the unzipped size of the function plus all its layers must stay within 250 MB. Layers do not raise the total, so 1.4 GB would still not fit. Learn more: Lambda quotas (opens in a new tab)
C. Wrong: Uploading through S3 avoids the 50 MB limit for direct uploads, but the unzipped contents must still be within 250 MB. A 1.4 GB package is still rejected. Learn more: Lambda quotas (opens in a new tab)
D. Wrong: A function connects to EFS over a VPC, which conflicts with the requirement not to attach it to a VPC. The libraries would also be read over the network instead of shipping with the function. Learn more: Lambda with Amazon EFS (opens in a new tab)
Explanation
Zip packages are limited to 250 MB unzipped, layers included, and S3 uploads do not change that. Container images can be up to 10 GB, ship the dependencies with the function and need no VPC. EFS would meet the size need but requires a VPC and loads files over the network.
Want more on Packaging and application configuration? The 5 full-length practice sets have 15 more Packaging and application configuration questions, 390 in all, none of them in the free exam. One payment of $14.99, no subscription. See the practice sets →