A latency-sensitive AWS Lambda function behind Amazon API Gateway shows slow first responses after idle periods because of cold starts, and traffic is predictable during business hours. The developer wants to keep initialized execution environments ready so those requests avoid cold-start latency. Which setting should the developer configure?
- AIncrease the function timeout so cold starts have more time to finish
- BSet reserved concurrency to zero during business hours
- CMove all initialization code into the function handler so it runs on every invoke, adding startup latency to each request instead of reusing a warm environment
- DConfigure provisioned concurrency on the function's alias for the expected number of concurrent requests
Provisioned concurrency pre-initializes and keeps warm a configured number of execution environments on an alias or version, so predictable business-hours traffic is served without cold-start latency. A larger timeout does not remove initialization time, zero reserved concurrency disables the function, and running init inside the handler adds cost to every call.
Why each option is right or wrong.
- D (correct). Provisioned concurrency keeps a set number of environments initialized and warm, removing cold-start latency.
- A. A longer timeout does not remove the initialization delay a cold start adds to the first response.
- B. Reserved concurrency of zero would stop the function from running at all.
- C. Moving init into the handler makes every invocation pay the initialization cost, worsening latency.
Reference: AWS Lambda provisioned concurrency; DVA-C02 Domain 1 (Development with AWS Services).