
Firstly, our functions are effectively stateless. This means that if we are undergoing a usage spike, the cloud provider simply creates multiple instances of the container with our function to serve those requests. If additional requests are made while the original event is being served, a new container is brought up to serve a request. It is brought up when an event takes place and is turned off if it is not being used. The container (and the resources used by it) that runs our function is managed completely by AWS. We will go over this in detail later on in this guide. To help us with this process we use the SST. And letting AWS know that you want to use this package when a specific event takes place. This is usually a process of compressing the function and all its dependencies and uploading it to an S3 bucket. Lambda functions need to be packaged and sent to AWS. After we do all the work inside our Lambda function, we simply call the callback function with the results (or the error) and AWS will respond to the HTTP request with it. The context object contains info about the runtime our Lambda function is executing in. In the case of an HTTP request it’ll be information about the specific HTTP request.

The event object contains all the information about the event that triggered this Lambda. Here myHandler is the name of our Lambda function.

Lambda Functionįinally here is what a Lambda function using Node.js looks like. We will take a look at the packaging process below. If you need more space, you can package your container as a Docker image which can be up to 10GB. There is a limit of 250MB on the uncompressed package and a 50MB limit once it has been compressed. This includes any dependencies ( node_modules/ directory in case of Node.js) that your function might import.
#Ephemeral storage lambda code#
The package size refers to all your code necessary to run your function. This means that Lambda isn’t meant for long running processes. The execution duration means that your Lambda function can run for a maximum of 900 seconds or 15 minutes. We will talk a bit more on the stateless nature of the Lambda functions below. You can only use this space for temporary storage since subsequent invocations will not have access to this. The ephemeral disk space is available in the form of the /tmp directory.

As you increase the memory, the CPU is increased as well. This is because you cannot control the CPU directly. You might notice that CPU is not mentioned as a part of the container specification.
