AWS Certified Developer – Associate — Question 348
A logistics company built an asset-tracking microservice by using the AWS Serverless Application Model (AWS SAM). One of the microservice’s AWS Lambda functions needs to import a large geospatial dataset from Amazon S3 before the function can process the requests. The import of the dataset requires significant time and is causing the function to take too long to finish running. The results are increased latency and cost.
A developer needs to optimize the function to process requests faster with the least possible cost.
Which solution will meet these requirements?
Answer options
- A. Store the geospatial dataset on Amazon Elastic File System (Amazon EFS) instead of on Amazon S3. Attach the EFS file system to the function. Retrieve the dataset by accessing the file system for every invocation.
- B. Store the geospatial dataset on Amazon Elastic File System (Amazon EFS) instead of on Amazon S3. Attach the EFS file system to the function. Cache the data in the /tmp directory for use with every invocation.
- C. Declare the Amazon S3 SDK and object request outside of the function handler. Configure provisioned concurrency for the function.
- D. Declare the Amazon S3 SDK and object request outside of the function handler. Increase memory capacity of the function to 1,769 MB.
Correct answer: C
Explanation
Initializing the Amazon S3 SDK and downloading the dataset outside of the Lambda handler allows the data to be retrieved during the initialization phase and retained in memory for subsequent warm starts. Combining this with provisioned concurrency ensures that execution environments are pre-warmed before requests arrive, completely eliminating cold-start latency associated with the large file download. Mounting Amazon EFS introduces unnecessary filesystem overhead and configuration complexity, while simply increasing memory limit to 1,769 MB does not solve the cold-start retrieval delay.