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?
AWS Lambda SnapStart is designed to improve the cold start performance of Java Lambda functions by initializing the function, taking a snapshot of the execution environment, and then reusing that snapshot for subsequent invocations. However, some code (such as code that generates unique IDs or session-specific data) should run during each invocation, not during the snapshot process. By using a pre-snapshot hook and moving the unique ID generation into the handler, you ensure that non-deterministic or per-invocation code is executed correctly, while the rest of the initialization benefits from SnapStart. This delivers the lowest latency and cost, as you do not need to pay for provisioned concurrency.
AWS Documentation Extract:
'Lambda SnapStart is ideal for Java functions with long cold starts due to heavy initialization. Move non-deterministic code such as unique ID generation to the handler, and use pre-snapshot hooks to customize what gets snapshotted. SnapStart works only for published versions, not $LATEST.'
(Source: AWS Lambda documentation, Using SnapStart for Java Functions)
Other options:
A: SnapStart is not supported for the $LATEST version; must be a published version.
B & C: Provisioned concurrency removes cold starts but is more expensive than SnapStart for most workloads.
C: You must use SnapStart on published versions, but provisioned concurrency is not required for SnapStart and adds cost.
Tiera
2 hours agoCarman
6 days agoTricia
11 days agoRex
17 days agoLanie
22 days agoGene
28 days agoDemetra
1 month agoPaz
1 month agoBarney
2 months agoEladia
2 months ago