What is Amazon AWS Lambda?
In this blog, we will discuss the concept of AWS Lambda which a serverless compute service offered by the Amazon. You must be wondering when there are so many compute services like Amazon EC2, AWS Elastic beanstalk, AWS OpsWorks, Lightsail etc are available already then what is special with AWS Lambda services?
Here, you will explore what is AWS Lambda, and where should you use it. Let us start our discussion with basic concepts first then we will deep dive to a practical example of Lambda services later.
What is AWS Lambda? How does it work?
AWS Lambda is a serverless compute service that lets you run code without provisioning any servers with less administrative overhead. All you need to concentrate on the code part for the applications. There is no charge for the code when it is not running.
This Lambda compute service provisions or de-provisions the infrastructure resources of AWS cloud as well. It is one of the easy ways for managing the AWS resources automatically. It also works on instances by launching or terminating them, checking their health, helps in auto-scaling, updates etc.
The code that you wanted to run with the help of AWS lambda is a Lambda function. So, you must be familiar with the fact that function runs only when it is called. So, the event source is an entity here that triggers the Lambda function and helps in execution of task as well.
All you need to do is supply your code in one of the languages that AWS Lambda supports.
Let us understood the concept in deep with the help of an example below –
Consider you are having an application for the image uploads in the cloud. So, each and every time if you are uploading an image into the cloud, will in-turn generate some events in the cloud. Events are nothing but the state changes of a particular matter. These events which are generated by uploading the images will trigger lambda function to execute the code. Simply the manual task is to write the lambda code in the console and also to define the event source properly.
As you can see in the image given above, the images are uploaded in the source bucket in the form of objects. The image upload action will generate an Event in the cloud. These Events will become the Trigger for the particular Lambda Functions. As you can see the whole process is divided into five major steps, let us understand each of them one by one below –
- The user will upload the image in the form of objects into the Source S3 bucket
- Amazon S3 will generate the Notifications/Events for the uploaded Image object.
- Now, it will send the notification/Events to the Lambda function which is acting as a trigger for the Lambda functions.
- Now, the execution role is managed in Lambda by IAS i.e. identity access management, the key service to manage the permission for AWS resources.
- In the last step, the desired Lambda function is invoked
If the same scenario needs to be managed traditionally with development then you need resources to manage the given tasks –
- Sizing, grouping, or scaling the group of servers
- Working on OS updates
- Security patch management
- Monitoring infrastructure for performance or availability.
This was quite tiring or boring task earlier and quite expensive too. So, the use of a robust compute service like AWS Lambda is quite justified here. This is compatible with Node JS, Python, Java etc so you can upload files in zip format too and define the event source finally. Congrats, you are done.
When to use Lambda?
If you are a solution architect, you must be trying to figure out when to use Lambda. You have the following options to manage your infrastructure, Amazon EC2, AWS OpsWorks, AWS Elastic Beanstalk, and AWS Lambda. Consider the above example again, why we used Lambda there, not other compute services.
AWS OpsWorks and AWS Elastic Beanstalk majorly required for app deployment but our task is to execute the backend code based on the cloud event triggers, not to create an application. So, EC2 could be another option here. But in the case of EC2, you need to manage everything and it is costly. In the case of Lambda, you don’t have to worry about anything, just paste the code and rest will be managed by the compute service itself.
That’s all for the day. This is clear from the discussion that tasks with AWS Lambda are never tedious and boring but they are quite reasonably priced too. Still, if your requirements don’t fit here then you can try other AWS compute services based on project needs and requirements. We wish you luck for a successful implementation!
The post AWS Lambda appeared first on Besant Technologies | No.1 Training Institute in Chennai, Bangalore & Pune.