More then 1s of cold start in our front-facing lambda

492 views Asked by At

we recently noticed that in our Customer facing function (lambda that consumed by APIGW) in our platform, we experiencing around ~1s of cold start. It's a lot for us and we are trying to fight this.

REPORT RequestId: 2545824b-66a3-44d2-871d-0abd7b5aa468 Duration: 213.83 ms Billed Duration: 300 ms Memory Size: 512 MB Max Memory Used: 91 MB Init Duration: 1059.00 ms

Tech details:

  • We are using nodejs v12.
  • We already tried to reduce the package size and use Layer for the dependencies (didn't help a lot)
  • The lambda itself is just querying some data form DyanmoDB, parse it, and retrieve to our users

Any suggestion to improve the latency? Any workarounds?

1

There are 1 answers

0
Ryan H Lewis On

There are a couple methods for solving cold start issues in Lambda functions:

  1. Use Provisioned Concurrency. It does add additional cost, but it should help your issue. https://aws.amazon.com/blogs/aws/new-provisioned-concurrency-for-lambda-functions/
  2. Invoke the function before AWS unloads it. You could set a CloudWatch alarm for this, or you could use a plugin if you're using something like the Serverless framwork. https://www.serverless.com/blog/keep-your-lambdas-warm

Good luck!