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 réponse
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
EXPERT
répondu il y a 2 ans
profile picture
EXPERT
vérifié il y a 24 jours

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions