AWS Certified Solutions Architect – Professional (SAP-C02) — Question 481
A company is developing a latency-sensitive application. Part of the application includes several AWS Lambda functions that need to initialize as quickly as possible. The Lambda functions are written in Java and contain initialization code outside the handlers to load libraries, initialize classes, and generate unique IDs.
Which solution will meet the startup performance requirement MOST cost-effectively?
Answer options
- A. Move all the initialization code to the handlers for each Lambda function. Activate Lambda SnapStart for each Lambda function. Configure SnapStart to reference the $LATEST version of each Lambda function.
- B. Publish a version of each Lambda function. Create an alias for each Lambda function. Configure each alias to point to its corresponding version. Set up a provisioned concurrency configuration for each Lambda function to point to the corresponding alias.
- C. Publish a version of each Lambda function. Set up a provisioned concurrency configuration for each Lambda function to point to the corresponding version. Activate Lambda SnapStar for the published versions of the Lambda functions.
- D. Update the Lambda functions to add a pre-snapshot hook. Move the code that generates unique IDs into the handlers. Publish a version of each Lambda function. Activate Lambda SnapStart for the published versions of the Lambda functions.
Correct answer: D
Explanation
AWS Lambda SnapStart is a free feature that significantly reduces startup latency for Java functions by utilizing cached snapshots of initialized environments, making it highly cost-effective compared to Provisioned Concurrency. Because SnapStart captures the initialized state of the JVM, any logic that generates unique data (such as unique IDs) must be moved inside the handler or managed with runtime hooks to prevent duplicate values across invocations. Option D correctly implements these code changes and enables SnapStart on published versions, which is required since SnapStart does not support the $LATEST version.