In today's topic, we'll be taking a look at AWS Lambda which is serverless compute service offered by Amazon. We'll see how it works and learn about such features and at the very end of this post, we create our own Lambda function and add an event to it so that it gets triggered. 

So stick till the end of the post and let's get started. So let's get started and define our agenda.

AWS Lambda

We'll start by talking about what is AWS Lambda followed by its features. After that, we'll see how Lambda works and then learn about its pricing structure. And at the very end, we'll have a demo in which we will create our own Lambda function and add an event so that it gets triggered. 

What is AWS Lambda? 

According to our mission, AWS Lambda is a serverless compute service. What this means is that developers don't have to worry about which AWS resource to launch or how they are going to manage those resources. All that is needed is just to put the code on Lambda and it gets executed. It's that simple. 

This not just saves time but also allows developers to focus on other major areas for service improvement. And AWS Lambda is used to execute backend code by automatically managing the AWS resources. And when we say manage, it involves starting or ending instances or running checkups or updating or patching for new updates. 

Features of AWS Lambda 

So what are the features of AWS Lambda? Well, there are so many features that come to mind. So here we'll list eight major features. 

Allows User to Build Custom Backend Services

The first one is AWS allows you to build custom backend services. You can use AWS Lambda to create new backend application services figured on demand using the Lambda API. Lambda processes custom events instead of servicing these on the client, helping you avoid client platform variations, reduce battery drain and enable easier updates. 

Can Use Third Party Library 

Coming on to our next point, let us bring your own code with Lambda. With AWS Lambda, there are no new languages or tools or even frameworks to learn. You can use the third party libraries or even native one and you can also package any code as a Lambda layer and manage and share them across multiple functions. 

Automated Administration 

So coming on to the next point, it is completely automated administration. AWS Lambda manages all the infrastructure to run your code on highly available, all tolerant infrastructure, bring you to focus on building differentiated backend services. With Lambda, you never have to update the underlying operating system when a patch is released, or worry about resizing or adding new servers as your usage goes. 

Extend other AWS Services with Custom Logic

Moving on to our next point, it extend other AWS services with custom logic. Well, the thing is AWS Lambda allows you to add custom logic to AWS resources such as S3 bucket or DynamoDB tables so that you can easily apply compute to data as it enters or moves through the cloud. It is easy to get started with Lambda. First to create your function by uploading your code right into the Lambda console, then you choose the memory, then the IM role, and then you specify the AWS resource to trigger the function, which can be a particular S3 bucket, DynamoDB table or even.

Automated Scaling 

Now for our next point, it is automated scaling. Well, the thing is AWS Lambda moves your code only when needed and automatically scales to support the rate of incoming requests without any manual consideration. So there's no limit to the number of requests your code can handle. AWS Lambda typically starts running your code within milliseconds of an event. And since Lambda scales automatically, the performance remains consistently high as the event frequency increases. 

Orchestrate Multiple Functions 

The sixth point, and that is orchestrate multiple functions. Well, you can build AWS step functions workflow to coordinate multiple AWS Lambda functions for complex or long running tasks. Step functions let you define workflow that trigger a collection of Lambda functions using sequential parallel branching and error handling steps. With step functions and Lambda, you can build stateful long running processes for applications and backends. 

Trust and Integrity Control 

Moving on to our next point, it is the trust and integrity control. Well, code signing for AWS Lambda allows you to verify that only unaltered code published by approved developers is deployed in your Lambda function. You can simply create digitally signed code artifacts and configure your Lambda functions to verify the signature at the deployment. This increases the speed and agility of your application development, even with the last theme, while enforcing high security standards. 

Flexible Resource Mode

And finally, let's talk about Lambda's flexible resource mode. Well, you can choose the amount of memory you want to allocate to your function and AWS Lambda allocates proportional CPU power network bandwidth disk input and output. 

How AWS Lambda Work

Now let's talk about how Lambda works. For me you may already know a function runs only when it is called. So the event is the source which triggers the Lambda function and then the task is executed. 

Let's take an example in order for you to understand this in that you have an app for image uploading. Now when you want to upload an image there are various tasks involved such as storing, resizing or compressing. For the task of uploading it can be thought of as an event source for a trigger. This trigger calls Lambda function and then all these tasks can be executed using Lambda function. In this example the developer needs to define event source and uploads the code. Let's say in this instance we will be uploading image in object form to S3 bucket. This uploading activity becomes the event source or the trigger. This entire process can be defined into five steps. The first step will be the user uploads image or the object to the bucket which has notifications attached to it for the Lambda function. Now the second step would be this notification is read by S3 and decides where to send the notification. This notification is sent to Lambda and it acts as an info call to the function. Execution role in Lambda can be defined in the IAM or identity and access management to give access permission for AWS resources. Like in this example where S3 uploading image action was used as a trigger to invoke the required Lambda function. 

AWS has essentially provided the Lambda service an order to streamline lots of processes in order to save developers time. The developer can therefore focus on the co-competencies of whatever products they are working on whether it be an app, a website or even any other service. Lambda also follows the paper you serve. This means that you pay for only what you use. You are charged based on the number of requests you make to your function and also the duration for which your code executes. When that comes to the request you are charged for the number of requests you make across all the Lambda functions. 

So AWS Lambda counts the requests each time it starts executing in response to an event source. The duration is calculated from the moment the code starts executing till it either terminates or returns. 

This is rounded up to the nearest hundred of milliseconds and the price depends on the amount of memory you allocate to your function. 

I hope that this session motivates you to get started in your career journey or even learn AWS for fun and as always if you have any questions do comment them and we will get back to you as soon as possible. Thanks 

Print this post