- Newest
- Most votes
- Most comments
What is your Lambda function doing? Is it calling external APIs? Could it be that those are causing a delay that you're seeing?
Without knowing what the code is doing it's not easy to provide advice.
If it were me I would be using some sort of logging or tracing inside the code to see where the delays are happening.
Hello.
How about setting up provisioned concurrency?
Perhaps your Lambda is running slower due to cold starts.
Setting provisioned concurrency helps reduce cold start latency.
https://docs.aws.amazon.com/lambda/latest/dg/provisioned-concurrency.html
Provisioned concurrency – This is the number of pre-initialized execution environments allocated to your function. These execution environments are ready to respond immediately to incoming function requests. Provisioned concurrency is useful for reducing cold start latencies for functions. Configuring provisioned concurrency incurs additional charges to your AWS account.
Also, although this is not very relevant, Node.js14 is a deprecated runtime, so I recommend updating to a newer runtime version if possible.
https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html#runtimes-deprecated
I updated the runtime to Node.js 20 and now the latency seems to be more frequent. Why should I configure provisioned concurrency, since worked just fine ?
Relevant content
- asked 2 years ago
- Accepted Answerasked 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 6 months ago
- AWS OFFICIALUpdated 2 years ago
The lambda is connecting to other AWS services, Secrets Manager, Postgres, SES. All of them are taking up to 4 seconds each in one session. I've updated initial post
In that case my advice is the same: put some instrumentation/logging into your function to see where the delay is coming from.
Yes, we've already did this, simple post request to SES with AWK SDK .NET takes 4seconds sometimes, other times takes 0.1seconds. When this is happening all other AWS services request takes a lot of time. Opening a connection to Postgres DB, getting secrets from Secrets Manager
Ok - what is the cause of the extra time? Is it DNS lookup? Is it because there are multiple IP addresses in the DNS reply and the first does not respond? Is it something to do with TLS negotiation?