Is the lambda /tmp shared?

0

Hey guys,

I'm using a lambda that saves some parquets in s3 after some processing, during dataframe processing I save some files in the file system to be read during the process. I'm using EFS as a file system, but since they are temporary files and thinking about reducing costs, I wanted to change EFS and use /tmp from the lambda. Carrying out some tests some parallel executions of the lambda, I received some errors of tmp not found or of little space, however the temporary files are on average 20mb in size and I put 4 gb of tmp in the lambda. The question is, is this tmp shared across runs? If it is shared, is there a way to not share it?

profile picture
marcus
asked a year ago1105 views
2 Answers
2

As described in the following document, "/tmp" may be cached and therefore may be shared if functions are executed at the same time.
As far as I know, there was no way to prevent it from being cached.
A good countermeasure would be to delete the files when the process is finished.
https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtime-environment.html

Each execution environment provides between 512 MB and 10,240 MB, in 1-MB increments, of disk space in the /tmp directory. The directory content remains when the execution environment is frozen, providing a transient cache that can be used for multiple invocations. You can add extra code to check if the cache has the data that you stored. For more information on deployment size limits, see Lambda quotas.

profile picture
EXPERT
answered a year ago
EXPERT
reviewed a year ago
2

Lambda functions run within an execution environment. Each such execution environment runs a single request at a time. If we get multiple requests at the same time, Lambda creates new execution environments to handles those requests. If we get a request and we have an idle environment, we will let that environment handle the new request.

The /tmp folder is unique to each execution environment. This means that it is not shared between environments, but it is shared between different requests happening in the same environment (not at the same time).

profile pictureAWS
EXPERT
Uri
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions