Provisioned concurrency not resolving lambda cold start

886 views Asked by At

I have a very basic lambda function that get's invoked by AWS API Gateway and all the lambda does is just calls out to AWS SNS to send a text message. The lambda is versioned and configured with 1 provisioned concurrency with a status that reads "Ready"

I'm experiencing cold start latency of up to 13 seconds when invoking the versioned lambda for the first time after 20-30 minutes.

Below is the AWS API gateway log detailing how long it took to get a response back after invoking the versioned lambda with provisioned concurrency.

Thu Oct 15 19:32:06 UTC 2020 : Sending request to https://lambda.us-west-2.amazonaws.com/2015-03-31/functions/arn:aws:lambda:us-west-2:123456789:function:sms-service-lambda-dev-test-01:3/invocations
Thu Oct 15 19:32:19 UTC 2020 : Received response. Status: 200, Integration latency: 12550 ms

but all subsequent invocations are ran pretty quickly

Thu Oct 15 19:50:19 UTC 2020 : Sending request to https://lambda.us-west-2.amazonaws.com/2015-03-31/functions/arn:aws:lambda:us-west-2:123456789:function:sms-service-lambda-dev-test-01:3/invocations
Thu Oct 15 19:50:20 UTC 2020 : Received response. Status: 200, Integration latency: 713 ms

Any ideas what I may be missing?

1

There are 1 answers

0
pahnman On BEST ANSWER

I was able to debug this more granularly and found that the cold start is actually occurring on the Amazon SNS side.

When using the dotnet AWS SDK to publish a message to AWS SNS, I found that the initial call out to AWS SNS seems to have a cold start taking around 7 seconds, and all subsequent calls to AWS SNS takes less than a second.

PublishResponse pubResponse = await snsClient.PublishAsync(pubRequest);