Posted on November 10, 2021 at 01:56 PM
Before talking about AWS Lambda function, let us understand the term serverless.
Serverless is a cloud based development approach. The developer focuses more on writing code and solving their business problems while the server is managed by AWS professionals. The advantage of a serverless application could be seen when auto-scaling the application. Not too long ago, developers had to anticipate application usage and add servers accordingly.
But, with the advent of serverless approach, bandwidth required to support the operation is managed by AWS. Resources could be scaled up or down depending on the computing needs at the time and you pay only for the resources you use.
The pay-as-you-go billing model helps teams to save time and money and be more focussed on customers’ needs.
Now get back to our main topic.
Definition as given on AWS, “AWS Lambda is a serverless, event-driven compute service that lets you run code for virtually any type of application or backend service without provisioning or managing servers”, describes a serverless approach in a nutshell.
Using AWS Lambda has its own merits and demerits. Here I’m listing some of them.
AWS Lambda limit to amount of compute and storage resources. The limits are applied in each region and could be increased.
Its limitations could be categorized into two categories:
Soft limits are those that are set as default values. They vary according to the region and could be increased by putting requests to the AWS support team. These limits are related to
Hard limits are those which could not be modified even by the AWS support team. These limits are related to the
A function is a program that is invoked by the Lambda. Lambda sends invocation events into the function which then processes the events and returns their responses.
It is the function execution environment selected to run the code. Runtime matches the language selected for the function.
Event source is an AWS service that triggers the function. Eg: HTTP request through API Gateway, SQS message available event, etc.
The Lambda function imports several libraries and dependencies and zip them as a part of the build and deployment process. A Lambda layer is an archive that could be used to store additional code, such as dependencies and libraries, separated from the main build.
Steps are given as below:
Alternatively, instead of manually entering code in the editor, you could zip the files and upload the zip file by clicking the button ‘Upload from’ as seen in the image at the top-right corner.
[Note: Size of total un-zipped files and folders could not be more than 250MB. See the chart shown above in the section ‘Limitations of using AWS Lambda’. To upload the code of size more than 250MB you could use an Elastic Container Register(ECR) image which is the topic for some other day. ]
Now, your code is ready to test from the AWS console.
As discussed above, Lambda could be triggered by the events from other AWS services. Lets create an API gateway to trigger the lambda function.
Steps to add API Gateway as a trigger:
AWS lambda is a serverless compute service which has the benefit of worry free auto-scaling. An event source in AWS could be used to trigger the Lambda function.
There are few restrictions with Lambda functions, but they have some thought behind them. It is meant to protect the developer from unintentional behaviour. To make most of AWS Lambda, the developer must be aware of these limitations.
We could talk tech all day. But we’d like to do things too,
like everything we’ve been promising out here.