Question

Difficulty: HardServerless Development with AWS Lambda

A developer is deploying a critical update to a serverless API backend running on AWS Lambda. The application handles high-velocity flash sales where traffic spikes instantly. To eliminate cold start latencies, the developer configures Provisioned Concurrency for the Lambda function. The API backend is integrated with an Amazon API Gateway HTTP API.

During deployment, the developer uploads the new function code, publishes Version 22 of the function, and associates Provisioned Concurrency with Version 22. However, when testing the API Gateway endpoint that routes traffic to the function using the LATEST\text{LATEST} identifier, clients still experience significant cold start latencies, and CloudWatch metrics show that the provisioned concurrency is not being utilized.

What should the developer do to ensure that the API Gateway endpoint utilizes the provisioned concurrency?

  1. Update the API Gateway integration to target a specific Lambda alias or a published function version that has Provisioned Concurrency configured, rather than targeting the LATEST\text{LATEST} identifier.Answer
  2. B
    Increase the execution timeout of the Lambda function and modify the function code to execute a dummy helper request before handling the main request to pre-warm the execution environments.
  3. C
    Add the `lambda:InvokeFunction` permission for the Provisioned Concurrency execution role inside the function's IAM trust policy to allow execution environments to be pre-created.
  4. D
    Deploy the Lambda function in multiple private subnets across different Availability Zones and attach a NAT Gateway to ensure the provisioned environments can communicate with API Gateway.

Answer

Update the API Gateway integration to target a specific Lambda alias or a published function version that has Provisioned Concurrency configured, rather than targeting the LATEST\text{LATEST} identifier.
Provisioned Concurrency initializes a specified number of execution environments so that they are prepared to respond immediately to your function's invocations. However, AWS Lambda does not allow you to configure Provisioned Concurrency on the LATEST\text{LATEST} version of a function, and any invocations that target the LATEST\text{LATEST} identifier directly or through an alias pointing to LATEST\text{LATEST} will not utilize provisioned concurrency. Therefore, the API Gateway integration must be updated to target a published version or an alias pointing to a published version (such as Version 22) that has Provisioned Concurrency configured.

Step-by-Step Solution

1
Analyze the invocation path of the AWS Lambda function from API Gateway.
Identify that the API Gateway endpoint targets the LATEST\text{LATEST} identifier of the Lambda function.
To determine why the configured Provisioned Concurrency is not being utilized during invocation.
2
Review the AWS Lambda Provisioned Concurrency specifications and restrictions.
Understand that Provisioned Concurrency cannot be associated with or invoked through the LATEST\text{LATEST} identifier; it must be mapped to a specific published version or alias.
To identify the root cause of the cold start latency despite configuration.
3
Modify the routing configuration of the API Gateway and the Lambda function targeting.
Update the API Gateway integration target to point to a Lambda alias (e.g., pointing to Version 22) or directly to Version 22, which has Provisioned Concurrency active.
To route incoming API Gateway traffic to the pre-warmed execution environments.

Key Concept

AWS Lambda Provisioned Concurrency Routing and Versioning Rules
Estimated Time:2m 0s
Rate this question