skip to Main Content

I have a lambda that gets as input array of values. The lambda’s task is to download some data and compare each item in the array with the downloaded data. The comparison is performed by invoking the same lambda with the item in the array.

My question is, can i share data between the invocations? Because the data that i compare it with is weighting about 1/2 Mb’s. I dont want to download the same data over over?

If there isn’t a way to do so, can you pls advice about ways to approach this problem?

i have looked the /tmp file but no one guarantee that the subsequent invocation would be served from same container. and if they arent served from the same container, they cant share the /tmp file.

3

Answers


  1. You can check Lambda caching. You are able to cache some data between invocations in scope of one container.

    Login or Signup to reply.
  2. You are correct that subsequent invocations of a Lambda function may not be served from the same container, and therefore, you cannot rely on sharing data via the /tmp directory between invocations. Each invocation of a Lambda function is stateless and isolated from previous invocations.

    To address the Issue, you can store the data somewhere external, like EFS, S3 or any other store (Lambda layer might also be a good option)

    Login or Signup to reply.
  3. If the data to be fetched never changes, then fetch it when you compile the JS and put it into the lambda’s deployment packaged.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search