A company is building a latency-sensitive application. Several Java AWS Lambda functions perform library loading, class initialization, and generation of unique IDs in initialization code outside the handler. The functions must initialize as fast as possible. Which approach is the most cost-effective to meet startup performance requirements?
Choose an answer
Tap an option to check your answer.
Correct answer: Add a pre-snapshot hook to the Lambda functions and move the code that generates unique IDs into the handlers. Publish a version of each function and enable Lambda SnapStart for the published versions..
Why this is the answer
The correct approach leverages Lambda SnapStart for faster initialization by pre-initializing the execution environment. Moving unique ID generation into the handler ensures each invocation gets a unique ID, as SnapStart restores a frozen execution environment, which would otherwise reuse the same ID. A pre-snapshot hook allows custom logic to run before the snapshot is taken, ensuring the environment is ready. Publishing a version is a prerequisite for SnapStart. Option 1 is incorrect because moving all initialization to the handler defeats the purpose of SnapStart, and SnapStart works with published versions, not $LATEST. Option 2 is incorrect because while provisioned concurrency reduces cold starts, it's more expensive and less effective than SnapStart for optimizing initialization time of the runtime itself. Option 3 is incorrect because it misses the crucial step of handling unique ID generation, which would lead to incorrect application behavior due to reused IDs from the snapshot.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed