

That is why when building applications that rely on ephemeral storage, you cannot rely that there will be something in there.


But when the function is destroyed, the files inside the ephemeral storage are deleted. This means that there can be something in the /temp directory if you don't clean it before the function ends its execution. However, different Lambda invocations in the same warm execution share the storage space. In addition, this storage is not shared between different functions. When you deploy your function, you set the storage space and you cannot change it without redeploying the function. Until few weeks it was only 512MB and now we can configure it up to 10GB. This is a powerful integration for event-driven architectures.Įphemeral storage refers to the storage capability inside the execution environment of your Lambda function. When we want to do something when a file is created, modified or deleted. When we want to trigger Lambda functions from the lifecycle of the object.However, when working with Lambda, you need to transfer that file to the function and that can be slow and also you might need to do some processing locally. When you need to work with huge files.For example, after one application processes the videos, another application takes the videos and uploads them to the system so they can be played and another application grabs the video metadata and adds it to the administrative portal. When you need to have shared objects between multiple applications.These functions are sharing the video object. The first function will resize it, then the second will add the transcribe it and the third one will add the subtitles. For example, you want to process a video. When you need to have shared objects between multiple applications or functions.When you are working with data lakes and you have multiple Lambda functions consuming and creating objects.This is because the objects are not inside the function, and they need to be transferred from the S3 service to the Lambda service. From outside, it might look that you can have folders inside the buckets, but those folders are just a prefix for the object name.Īlso, S3 speed for retrieving objects is the slowest of all the storage options available for Lambda. However, S3 is not a file system, it has a flat hierarchical organization. In the following example, you can see how you can trigger a Lambda function when a new file is created in an S3 bucket and also how you can write into an S3 bucket from a function. Simply give permissions from the Lambda functions to access the bucket and the bucket to trigger the function, and you are good. The integration between these two services is simple to set up as none of the services needs a VPC. This means that you can store and retrieve objects from the Lambda functions in S3, but also you can trigger functions when objects suffer changes - added, changed or deleted. On the communication side, S3 and Lambda have a bi-directional communication. S3 high-availability means that when you store a file in S3, it will be there until you remove it. No matter how many functions run in parallel, S3 will scale according. On the operational side, Amazon S3 scales and is highly available. Amazon S3Īmazon S3 and AWS Lambda integration is simple, on the operational side and on how the two services communicate. I hope that after reading this you have more information to make better decisions when to choose one solution over the other. If you have new use cases, please let me know in the comments box.

In this post, I want to share with you four different ways to store files when using Lambda and some of the most common use cases. After that announcement, I got a lot of questions regarding when to use ephemeral storage over Amazon EFS or Amazon S3. A few weeks ago AWS Lambda added the capability to increase its ephemeral storage up to 10GB.
