SAP-C02 · Question #753
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…
The correct answer is C. Publish a version of each Lambda function. Set up a provisioned concurrency configuration for. To make latency-sensitive Java Lambda functions initialize as quickly as possible and cost-effectively, set up provisioned concurrency to keep execution environments pre-initialized.
Question
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?
Options
- AMove all the initialization code to the handlers for each Lambda function. Activate Lambda
- BPublish a version of each Lambda function. Create an alias for each Lambda function. Configure
- CPublish a version of each Lambda function. Set up a provisioned concurrency configuration for
- DUpdate the Lambda functions to add a pre-snapshot hook. Move the code that generates unique
How the community answered
(37 responses)- A8% (3)
- B3% (1)
- C84% (31)
- D5% (2)
Why each option
To make latency-sensitive Java Lambda functions initialize as quickly as possible and cost-effectively, set up provisioned concurrency to keep execution environments pre-initialized.
Moving initialization code into the handler would cause it to run on every invocation, drastically increasing the execution time for all requests, not just cold starts, and severely worsening overall latency.
Publishing Lambda versions and creating aliases are primarily for deployment management and traffic shifting, not for reducing cold start latency.
Setting up provisioned concurrency for AWS Lambda functions keeps a specified number of execution environments initialized and ready to process invocations instantly, effectively eliminating cold start delays for those instances. This is the most direct and cost-effective way to ensure latency-sensitive Java functions, with significant initialization code, start 'as quickly as possible' by avoiding cold starts.
While AWS Lambda SnapStart (which uses pre-snapshot hooks) significantly reduces cold start times for Java functions, it does not entirely eliminate them like Provisioned Concurrency. Additionally, managing non-idempotent initialization logic (like generating unique IDs) with SnapStart requires careful code adjustments to ensure correctness.
Concept tested: AWS Lambda Provisioned Concurrency for cold start reduction
Source: https://docs.aws.amazon.com/lambda/latest/dg/provisioned-concurrency.html
Community Discussion
No community discussion yet for this question.