AWS Lambda And Serverless Computing

Before we learn and understand one of the great feature provided by AWS, also known as AWS lambdas, let’s try to understand what Serverless Computing is.
Serverless Computing

Serverless Computing is a cloud computing execution model in which the cloud provider dynamically manages the allocation of machine resources. Pricing is based on the actual amount of resources consumed by an application.

We have couple of good Serverless Computing environments provided by Google and Amazon,

  1. Google Cloud Functions
  2. AWS Lambda 

In this article, we will focus and learn what AWS Lambda is, and how easily we can create serverless computing environment/ framework/ architecture at our finger tips.

Serverless Computing
AWS environment/package offers a ton of services like EC2, S3, API Gateway etc. AWS Lambda is one of them.

Serverless Computing

AWS Lambda falls under the Compute category.

Let’s speed up the gear and try to figure out the following:

Q - What does AWS Lambda do?

As we said, it is a serverless computing service provided by Amazon Web Services that runs your code/function in response to your events and manages the underlying computing resource for you. You don’t have to worry about the memory and server configuration and scaling. We can even use AWS Lambda to extend other services or any custom logic.

Q - Is it language agnostic?

AWS Lambda supports a wide range of languages. It can be written in Node.js, Python, Java, C# etc.

Q - How AWS Lambda function works?

When any AWS lambda function gets invoked, it manages and provides all necessary resources to start the functioning. We just specify some basic configuration like memory need for function, maximum execution time. If not provided, the default values will be considered.

Firstly, it sets up a container and some necessary bootstrapping to invoke the function which adds some more latency the first time function is invoked and later on, for every subsequent call, the same container is reused.

It maintains the container for some time and if the function is not called in that time period, resources are de-allocated.


When you write your Lambda function code, do not assume that AWS Lambda always reuses the container because AWS Lambda may choose not to reuse the container. Depending on various other factors, AWS Lambda may simply create a new container instead of reusing an existing container.

On the other side, there are some points/limitations needed to be considered.

Memory allocation rangeMinimum = 128 MB / Maximum = 1536 MB (with 64 MB increments)
Ephemeral disk capacity ("/tmp" space)512 MB
Number of file descriptors1,024
Number of processes and threads (combined total)1,024
Maximum execution duration per request300 seconds
Invoke request body payload size (RequestResponse)6 MB
Invoke request body payload size (Event)128 K
Invoke response body payload size (RequestResponse)6 MB

Let’s start with creating AWS Lambda.

  1. Login to your AWS account.
  2. Click on Lambda under Compute services.
  3. Click on “Create a Lambda function”, which brings the following screen.

    Serverless Computing
  1. We are considering “js 6.10” as “Select runtime” in this article and then choose Blank Function.
  1. Click "Next" as in below screenshot, since we aren’t covering triggers in this article.

    Serverless Computing
  1. This screen is the main screen where we configure all the necessary data.

    Serverless Computing
    • Name is just a function name
    • Description as needed
    • Runtime allows us to set the node runtime environment, in our example, it's set to 6.10
    • Lambda function code area allows you to write your code. In this article, we are using inline approach if you have a small source code. There are two other ways Upload as a Zip file and Upload from S3 as you will see this later. But for now, let’s keep it inline.
    • Lambda function handler and role allows us to specify the entry point of the function. In the screenshot, it is named as main where as main is the function name (can be any name). “index.main” will call exports.main.

Role defines the permission of your function whereas Existing Role pulls any existing role if any.

Tags are used to group and filter your functions. A tag consists of key-value pair. 

Advance Settings allow you to configure Memory & Timeout settings along with VPC settings if any.

  1. Once all this is done, click Next. The Review screen shows up for confirmation; click "Create function".

  2. In the next screen as below, click "Test" to invoke the function.

    Serverless Computing

You can see the console output as “Hello from Lambda” whereas Summary screen displays the detailed output as Lambda function duration, Max memory used etc.

So, in this article, we have learned about Serverless Computing along with AWS Lambda. We also learned how easy it is to create a Lambda function without worrying about resources. In the next article, we will dive deep into functions and its structure.

I hope you liked it.

Up Next
    Ebook Download
    View all
    View all