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일 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠