aws lambda function not able to create a new instance each time it is invoked and resuses old instances

0

Hi, I want my java aws lambda function to create a new instance each time it is invoked with a fresh environment.

But as of now it is reusing an existing aws lambda instance which is already created.

I tried setting AWS_LAMBDA_INITIALIZATION_TYPE environment variable to "on-demand" but it doesn't work.

How to achieve the desired outcome.

gefragt vor einem Jahr513 Aufrufe
2 Antworten
0

Hello,

According to AWS documentation, it's not possible to create a new instance with a fresh environment each time, since after the function and all extensions have completed, Lambda freezes the execution environment for some time in anticipation of another function invocation.

It doesn't always happen, so do not assume that Lambda automatically reuses the execution environment for all subsequent function invocations, but it is the default/expected behaviour.

profile picture
EXPERTE
beantwortet vor einem Jahr
EXPERTE
überprüft vor einem Jahr
0

Lambda was designed to reuse the execution environment between invocations to save on cold starts. Why do you need to create a new one for each invocation?

profile pictureAWS
EXPERTE
Uri
beantwortet vor einem Jahr

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen