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 Risposta
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
ESPERTO
con risposta 2 anni fa
profile picture
ESPERTO
verificato 24 giorni fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande