lambda take few seconds to return response

0

Hi team,

I created a custom lambda authorizer and attached it to my HTTP API GW authorizer.

1 - I noticed each time that the lambda authorizer is slow, it takes around 3 to 4 seconds to get the response (maybe it's due to my lambda reading secret keys from secret manager ?)

my lambda read apiKeys from secret manager and compares it with a custom header value on the HTTP request

2 - also, the lambda took more than 5 seconds to wake up.

Is there any way to solve this latency related to the lambda authorizer for these points?

Thank you

1 個回答
0

For the first part you might consider putting setup code outside the Lambda function handler so that it is only executed once (on cold starts).

For the second part: You don't say what runtime language you're using in Lambda; there are a lot of tips on the web and in our documentation for reducing cold start times for Lambda functions. I'd link to them but without knowing the language I'd suggest instead that you search for "lambda reduce cold start" and add your runtime there.

You might also consider using Lambda Provisioned Concurrency but bear in mind there is a cost for that.

profile pictureAWS
專家
已回答 2 年前
profile picture
專家
已審閱 24 天前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南