px06
px06

Reputation: 2326

Does AWS Lambda reset memory on each invocation?

I am currently using AWS Lambda in conjunction with Java 8. As far as I can see AWS Lambda is considered an isolated unit of work, i.e. each process can be done in isolation. In this case, upon a container being reused, would JVM or the Lambda container itself have persisted memory that the next execution could use? Does the Lambda memory reset at each invocation? I can't seem to find the answer to this in the docs.

Upvotes: 6

Views: 4428

Answers (2)

Pubudu Jayawardana
Pubudu Jayawardana

Reputation: 2365

Lambda can contain cached data from previous invocation, but it is not guaranteed and AWS doesn't provide any TTL when this cached be invalidated. This can be good if you need to use same data over and over within all the invocations. However, if you specifically need fresh invocation, make sure you flush cache/reset variables etc as first step of your function.

Upvotes: 2

Vikyol
Vikyol

Reputation: 5625

No, it does not wipe the memory. You should implement your own memory wiping process before your function terminates, if mandated.

Prior to a function’s first invocation, Lambda scrubs the memory before assigning it to an execution environment. However, Lambda does not scrub memory between subsequent invocations on the same execution environment for the same function to facilitate execution environment reuse.

You can read further details in Security Overview of AWS Lambda whitepaper.

Upvotes: 7

Related Questions