Log In to start Learning

Login via

Post By Admin Last Updated At 2020-06-15
AWS Lamdba

Till now, we have seen various services offered by Amazon. So today, in this block, we will be discussing one more service offered by Amazon. i.e AWS Lambda.

What is the need for AWS Lamda?

The need for AWS Lamda is explained with the following scenario.

Let us considers the website hosted on Amazon EC2 that currently serves 90-100 users in reading the content. And, On the other hand, and the admin uploads 10 videos on the website for processing. So it increases the server load. Besides EC2 provisions the number of instance for this task. This is because hosting and back end changes were taking place in the same instance. Moreover, Autoscaling takes a long time to provision the instances that initially slows down the website speed. So it seems to be a problem in Cloud computing. And we can solve this problem using distributed computing.

In this, the website is hosted on one instance and the backend code is hosted on another instance. So while the end-user reads the blogs, the admin can still upload the content to the website. Moreover, the website will forward the task of video processing to another instance.  So it does not impact the website performance.

What is AWS Lamda?

It is one of the event-driven and serverless computing service offered by AWS.

AWS Lamda is a stateless and serverless system that helps to run the background task in the most efficient way as possible.

Serverless does not mean it does not have the server, it means, we don't need to take care of server management, AWS will be taking care of that. It provides flexibility to the user to concentrate more on coding. Besides, AWS automatically allocates the required for the development in the environment.  Moreover, It supports the code written in various languages like JAVA, Python and NodeJs. Moreover, the best advantage of  AWS Lamda is you just have to pay for the resources you used.

AWS Lambda

So, we will create the lambda function in practical

step -1:

Login to Amazon account and search for lambda. And so you will be entering into the following screen.

AWS lambda

step - 2:

Click on Create Function.AWS lambda

 

step - 3:

Select the function type that you want to create.

AWS lambda

step - 3b:

Provide the function name and select the platform that you want to develop the code and click on create function.

AWS lambda

step - 4:

step - 4a:

Remove the existing code (It was initially in JSON) and develop your own code. And click on Save.

AWS Lambda

step - 4b:

Click on Test

AWS lambda

step - 5:

step - 5a:

provide the event name and assign the values as shown below.

AWS lambda

step -5b:

Scroll down and click on Create.

AWS lambda

step - 6:

Once again test the code.

AWS lambda

Then you can observe the actual output. Likewise not only on python, as mentioned above, but we can also perform the operations in any language and also in an amazon S3.

Visit AWS training to get real-time explanations
Benefits of AWS Lamda:

Like Amazon SWF types,  lambda task need not be registered.

It allows you to use the existing lambda functions that you have already defined in workflows

Moreover, Amazon SWF directly calls the lambda functions

It provides the metrics and logs for tracking function executions

Limitations of AWS Lamda:

Besides several benefits. AWS Lamda has some limitations. Those are:

  • The maximum execution duration per request is set to 300 seconds only
  • In the runtime environment, it provides the maximum of 512MB disk space.
  • The memory volumes vary in between  128 to 1536Mb.
  • It code execution time is only 15 minutes.
  • But Lambda function can write the logs to Cloud watch

The AWS lambda  resource limit is shown below

ResourceDefault Limit
Ephemeral disk capacity (“/tmp” space)512MB
File descriptors1024
Processors and threads1024
Maximum execution duration per request300 seconds
Invoke request body payload size6MB
Invoke response body payload size6MB

Also, check our blog on What is AWS Lambda