Categories: AWS

Introduction to AWS Lambda Part-1

AWS Lambda is a kind of API end-point that performs a single function and runs when a request is made. AWS Lambda does not have any server i.e. there is no need to manage or provision the servers. It executes the task whenever a request sent to it that is why it known as serverless architecture. You can also call it Function As A Service(FAAS) because you pay only for execution time but it is actually a Platform as a Service (PaaS) to perform backend tasks. It supports several languages such as Java, NodeJS, Python, C#, and Go.

“AWS Lambda is a compute service that lets you run code without provisioning or managing servers. AWS Lambda executes your code only when needed and scales automatically, from a few requests per day to thousands per second. You pay only for the compute time you consume – there is no charge when your code is not running.”

AWS Lambda Official Document

                                                                                            

Characteristics

  • It used to execute backend code without managing any server.
  • It is a highly flexible and scalable capability.
  • It acts as a Function As A Service(FaaS).
  • We can write lambda function in many languages such as Python, NodeJS, C#, Java, and Go.
  • We only need to pay as per usage, no need to pay when there is no backend request.

Core Components

  • Function: It is a small script that performs specific backend operations at a fixed time of 5 minutes.
  • Runtime: With the help of runtime we can run code written in multiple languages.
  • Event Source: Event sources triggers function execution. event source can be amazon service or customized service
  • Lambda Layers: It is used to maintain libraries and dependencies required to perform operations.
  • Log Streams: Handles logs of function with annotation so that we can easily analyze the performance of our lambda function.

How does AWS Lambda work?

In AWS Lambda, you need to define your task in terms of AWS function in Lambda Editor and setup service that triggers the Lambda event. Whenever an event triggers Aws lambda configure respond to the service by executing your written function with pre-configured resources. Finally, you need to pay as per your use, no need to pay for idle time.

Source: https://aws.amazon.com/lambda/

A Usecase of AWS Lambda

You can build powerful and faster web applications using AWS lambda. It has the capability to scale up and down. It offers highly available and preconfigured platforms. In the figure mentioned below, you can see whenever the user asks for local weather then the API gateway triggers the AWS Lambda function and extracts the data from Amazon DynamoDB.

Source: https://aws.amazon.com/lambda/

It can be also be used in a variety of applications such as  Alexa Chatbots, Trigger ETL events, real-time file processing, real-time stream processing, and automated Backups

Compare AWS Lambda and AWS EC2

AWS LambdaAWS EC2
Platform as a ServiceInfrastructure as a Service (IaaS)
It runs whenever a request made to it.It creates a virtual machine.
It is less flexible in terms of customized resources. e.g. you can use 4-5 languages only.It is more flexible in terms of customized resources. e.g. here there are no such limits you can use any environment or any of the language you want.
Its a readymade service you just need to push your script and start using service.It needs OS, software, and then you can push your script for execution.

Pros and Cons of AWS Lambda

AWS Lambda has various advantages such as easy to implement, flexibility, scalability, multiple language support, and support for logging information.  It reduces the bill compared to other server-based architecture because AWS charges based on the use of service. It only considers the memory usage, the number of requests made, and the execution time.

Aws lambda only supports AWS services. It is only suitable for small operations and projects such as Chatbot. It has a limitation of memory, execution time that is why you need to write your code with extra precautions.

Summary

Congratulations you have made to the end of this tutorial.

In this tutorial, we have focused on Aws lambda, its characteristics, components, working, usecase, comparisons with AWS EC2, and Pros and Cons of AWS Lambda. 

Avinash Navlani

Share
Published by
Avinash Navlani

Recent Posts

MapReduce Algorithm

In this tutorial, we will focus on MapReduce Algorithm, its working, example, Word Count Problem,…

8 months ago

Linear Programming using Pyomo

Learn how to use Pyomo Packare to solve linear programming problems. In recent years, with…

1 year ago

Networking and Professional Development for Machine Learning Careers in the USA

In today's rapidly evolving technological landscape, machine learning has emerged as a transformative discipline, revolutionizing…

1 year ago

Predicting Employee Churn in Python

Analyze employee churn, Why employees are leaving the company, and How to predict, who will…

2 years ago

Airflow Operators

Airflow operators are core components of any workflow defined in airflow. The operator represents a…

2 years ago

MLOps Tutorial

Machine Learning Operations (MLOps) is a multi-disciplinary field that combines machine learning and software development…

2 years ago