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 of the function, and associates Provisioned Concurrency with Version . However, when testing the API Gateway endpoint that routes traffic to the function using the 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?
- 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 identifier.Cevap
- BIncrease 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.
- CAdd 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.
- DDeploy 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.