What is AWS Lambda in Hindi?

Amazon released Lambda in 2015. You do not have to take care of managing Data centre, managing infrastructure as a service, managing platform as a service or container. You need to upload the code and Amazon will do everything for you.

AWS Lambda एक अमेज़न वेब सर्विस है इस पोस्ट में हम इसके बारे में अच्छे से जानेंगे What is AWS Lambda in Hindi की AWS Lambda किसे कहते है।

What is AWS Lambda in Hindi?

Before AWS Lambda function, let’s understand:

What is Serverless?

Serverless is a term that generally refers to serverless applications. Serverless applications are ones that don’t need any server provision and do not require to manage servers.

AWS Lambda is an event-driven, serverless computing platform provided by Amazon as a part of Amazon Web Services. Therefore you don’t need to worry about which AWS resources to launch, or how will you manage them. Instead, you need to put the code on Lambda, and it runs.

In AWS Lambda the code is executed based on the response of events in AWS services such as add/delete files in S3 bucket, HTTP request from Amazon API gateway, etc. However, Amazon Lambda can only be used to execute background tasks.

AWS Lambda function helps you to focus on your core product and business logic instead of managing operating system (OS) access control, OS patching, right-sizing, provisioning, scaling, etc.

What is Lambda?

  • Lambda is used to encapsulate Data centres, Hardware, Assembly code/Protocols, high-level languages, operating systems, AWS APIs.
  • Lambda is a compute service where you can upload your code and create the Lambda function.
  • Lambda takes care of provisioning and managing the servers used to run the code.
  • While using Lambda, you don’t have to worry about scaling, patching, operating systems, etc.

Lambda can be used in the following ways:

  • It can be used as an event-driven compute service where AWS Lambda runs your code in response to events. These events could be changes to data in an Amazon S3 bucket or an Amazon DynamoDB table.
  • It can be used as a compute service to run your code in response to HTTP requests using Amazon API calls made using AWS SDKs.

How does AWS Lambda work?

The following AWS Lambda example with block diagram explains the working of AWS Lambda in a few easy steps:

AWS Lambda Block Diagram

  • User uploads an image to S3.
  • S3 triggers an event, and this event is a Lambda function.
  • Lambda function takes this image, and then encode the image. When an image is encoded, it gets stored in S3.
  • The Lambda function might trigger other Lambda event which is returning image location back to the user.
  • The Lambda might trigger another Lambda event that takes the image from the S3 bucket and stores it in another S3 bucket located anywhere in the world.

Step 1: First upload your AWS Lambda code in any language supported by AWS Lambda. Java, Python, Go, and C# are some of the languages that are supported by AWS Lambda function.

Step 2: These are some AWS services which allow you to trigger AWS Lambda.

Step 3: AWS Lambda helps you to upload code and the event details on which it should be triggered.

Step 4: Executes AWS Lambda Code when it is triggered by AWS services:

Step 5: AWS charges only when the AWS lambda code executes, and not otherwise.

This will happen in the following scenarios:

  • Upload files in an S3 bucket
  • When HTTP get/post endpoint URL is hit
  • For adding/modifying and deleting Dynamo DB tables
  • In the process of data streams collection
  • Push notification
  • Hosting of website
  • Email sending

Events that Trigger AWS Lambda

Here, are Events which will be triggered when you use AWS Lambda.

  • Insert, updating and deleting data Dynamo DB table
  • To include push notifications in SNS
  • To search for log history in CloudTrail
  • Entry into an S3 object
  • DynamoDB can trigger AWS Lambda whenever there is data added, modified, and deleted in the table.
  • Helps you to schedule the event to carry out the task at regular time pattern.
  • Modifications to objects in S3 buckets
  • Notifications sent from Amazon SNS.
  • AWS Lambda can be used to process the CloudTrail logs
  • API Gateway allows you to trigger AWS Lambda on GET/POST methods.

AWS Lambda Concepts

Function:

A function is a program or a script which runs in AWS Lambda. Lambda passes invocation events into your function, which processes an event and returns its response.

Runtimes:

Runtime allows functions in various languages which runs on the same base execution environment. This helps you to configure your function in runtime. It also matches your selected programming language.

Event source:

An event source is an AWS service, such as Amazon SNS, or a custom service. This triggers function helps you to executes its logic.

Lambda Layers:

Lambda layers are an important distribution mechanism for libraries, custom runtimes, and other important function dependencies. This AWS component also helps you to manage your development function code separately from the unchanging code and resources that it uses.

Log streams:

Log stream allows you to annotate your function code with custom logging statements which helps you to analyse the execution flow and performance of your AWS Lambda functions.

How to use AWS Lambda

Now, we will learn how to use AWS Lambda with AWS Lambda example:

Step 1) Step 1) Open AWS Lambda URL
Goto https://aws.amazon.com/lambda/ and Get Started

Step 2) Create an account
Next, Create an account or sign in with your existing account

Step 3) Edit the code & Click Run,
In the next Lambda page,

  1. Edit the code
  2. Click Run

Step 4) Check output
You will see output

AWS Lambda VS AWS EC2

Here, are some major differences between AWS Lambda and EC2.

Parameters AWS Lambda AWS EC2
Definition AWS Lambda is a Platform as a Service (PaaS). It helps you to run and execute your backend code. AWS EC2 Is an Infrastructure as a Service (laaS). It provides virtualized computing resources.
Flexibility Does not offers any flexibility to log in to compute instances. It allows you to choose a customized operating system or language runtime. Offers the flexibility to select the variety of instances, customoperating systems, security patches, and network, etc.
Installation process You need to select your environment where you want to runthe code and push the code into AWS Lambda. For the first time in EC2, you have to choose the OS and install all the software required and then push your code in EC2.
Environment restrictions It is restricted to fewlanguages. No environment restrictions.

AWS Lambda VS AWS Elastic Beanstalk

Here, are some major differences between AWS Lambda and Elastic Beanstalk.

Parameters AWS Elastic Beanstalk AWS Lambda
Main task Deploy and manage the apps on AWS Cloud without worrying about the infrastructure which runs those applications. AWS Lambda is used for running and executing your Back-end code. You can’t use it to deploy an application.
Selection of AWS resources It gives you a Freedom to select AWS resources; For example, you can choose EC2 instance which is optimal according to your application. You can’t select the AWS resources, like a type of EC2 instance, Lambda offers resources based on your workload.
Type of system It is a stateful system. It is a stateless system.

Use Cases of AWS Lambda

AWS Lambda used for a wide range of applications like:

  • Helps you for ETL process
  • Allows you to perform real-time file processing and real-time stream processing
  • Use for creating web applications
  • Use in Amazon products like Alexa Chatbots and Amazon Echo/Alexa
  • Data processing (real-time streaming analytics)
  • Automated Backups of everyday tasks
  • Scalable back ends (mobile apps, loT devices)
  • Helps you to execute server-side backend logic
  • Allows you to filter and Transform data

Best practices of Lambda function

Here are some best practices of AWS Lambda functions:

  • Use the right “timeout.”
  • Utilize the functions of local storage which is 500MB in size in the /temp folder
  • Minimizing the use of start-up code which is not directly related to processing the current event.
  • You should use built-in CloudWatch monitoring of your Lambda functions to view and optimize request latencies.

When not to use AWS Lambda

Following are the situation where Lambda is surely not an ideal option:

  • It is not appropriate to use AWS Lambda software packages or applications which rely on calling underlying Windows RPCs
  • If is used for custom software applications with licensing agreements like MS-Office document processing, Oracle databases, etc.
  • AWS Lambda should not be used for custom hardware process such as GPU acceleration, hardware affinity.

Advantages of using AWS Lambda

Here, are pros/benefits of using AWS lambda:

  • AWS Lambda is a highly flexible tool to use
  • It helps you to grant access to resources, including VPCs
  • Author directly with WYSIWYG editor in console.
  • You can use it as a plugin for Eclipse and Visual Studio.
  • As it is serverless architecture, you don’t need to worry about managing or provisioning servers.
  • You do not need to set up any Virtual Machine.
  • Helps developers to run and execute the code’s response to events without building any infrastructure.
  • You just need to for the compute time taken, only when your code runs.
  • You can monitor your code performance in real time through CloudWatch.
  • It allows you to run your code without provisioning or to manage any other server
  • Helps you to execute the code only when needed
  • You can scale it automatically to handle a few requests per day and even support more than thousands of requests per second.
  • AWS Lambda can be configured with the help of external event timers to perform scheduled tasks.
  • Lambda function in AWS should be configured with external event and timers so; it can be used for scheduling.
  • Lambda functions are stateless so that it can be scaled quickly.
  • AWS Lambda is fast so it will execute your code within milliseconds.

Limitations of AWS Lambda

Here are the cons/disadvantages of using AWS Lambda:

  • AWS Lambda tool is not suitable for small projects.
  • AWS Lambda entirely relies on AWS for the infrastructure, so you can’t install any additional software if your code demands it.
  • Concurrent execution is limited to 100
  • AWS Lambda completely depended on AWS for the infrastructure; you cannot install anything additional software if your code demands it.
  • Its memory volume can vary between 128 to 1536 MB.
  • Event request should not exceed 128 KB.
  • Lambda functions help you to write their logs only in CloudWatch. This is the only tool that allows you to monitor or troubleshoot your functions.
  • Its code execution timeout is just 5 minutes.

Summary

  • Serverless is a term that generally refers to serverless applications.
  • AWS Lambda is one such serverless compute service. Therefore, you don’t need to worry about which AWS resources to launch, or how will they manage them.
  • A function is a program or a script which runs in AWS serverless Lambda.
  • Runtime allows functions in various languages which runs on the same base execution environment.
  • An event source is an AWS service, such as Amazon SNS, or a custom service.
  • Lambda layers are an important distribution mechanism for libraries, custom runtimes, and other important function dependencies.
  • Log stream allows you to annotate your function code with custom logging statements which helps you to analyse the execution flow and performance of your Lambda functions.
  • AWS Lambda is a Platform as a Service (PaaS). It helps you to run and execute your backend code.
  • AWS EC2 Is an Infrastructure as a Service (laaS). It provides virtualized computing resources.
  • Deploy and manage the apps on AWS Cloud without worrying about the infrastructure which runs those applications.
  • AWS Lambda is used for running and executing your Back-end code. You can’t use it to deploy an application.
  • AWS Lambda helps you for the ETL process.
  • The best practice of Lambda function in AWS is to use the right “timeout.”
  • It is not appropriate to use AWS Lambda software packages or applications which rely on calling underlying Windows RPCs
  • AWS Lambda is a highly flexible tool.
  • AWS Lambda tool is not suitable for small projects.
  • A common event which will be triggered when you use AWS Lambda is Insert, updating and deleting data Dynamo DB table.

Conclusion 

इस पोस्ट में हमने AWS Lambda अमेज़न वेब सर्विस के बारे में अच्छे से जाना। From the above example, we conclude that Lambda event can trigger another Lambda event and they can communicate with other AWS resources.

An important feature of Lambda is that it scales automatically. While using Lambda, you do not have to maintain Elastic Load Balancer. It either scales up or scales out based on the condition.

Scaling up means increasing the resources in terms of RAM such as 8 GB to 12 GB.

Scaling out means adding more and more instances. For example, Load Balancer. If load increases, you scale out rather than scaling up the instances. Lambda function scales out automatically. For example, if we have a two-line function, and millions of users hit the same function, millions of functions created to serve the millions of users.

 

Ravi Giri
Ravi Girihttp://hinditechacademy.com/
नमस्कार दोस्तों, मै रवि गिरी Hindi Tech Academy का संस्थापक हूँ, मुझे पढ़ने और लिखने का काफी शौख है और इसीलिए मैंने इस ब्लॉग को बनाया है ताकि हर रोज एक नयी चीज़ के बारे में अपने ब्लॉग पर लिख कर आपके समक्ष रख सकू।

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Must Read