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 Respuesta
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
EXPERTO
respondido hace 2 años
profile picture
EXPERTO
revisado hace 24 días

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas