AWS Lambda | Serverless | 2021

1 pOUCJiB5xiETtu5Hu1nY w

In this blog, I will cover – Why do we need AWS Lambda? What is Serverless? , Lab Exercise,  Anatomy of Lambda Function,  Architecture, Execution Model, Pricing.

Why do we need AWS Lambda?

When you are building the application that wants to deliver a great experience to your user. Maybe you want your application to generate in-app purchase options during a gaming session, rapidly validate street addresses or make image thumbnails available instantly after the user uploads photos.

To make this magic happen you need backend code that runs and responds like image upload, app activity. But managing the infrastructure that host and execute the backend code requires you to size, provision, scale bunch up servers, manage OS updates, security patches and then monitor all this infrastructure, performance and ability. With AWS Lamda you can focus on just the code part rather than managing servers. You just need to upload code and lambda will handle all things related to the server. You can even monitor using a cloud watch. All you need is to write and upload the code.

aws lambda

What does Serverless mean?

  1. No Servers to Provision or manage
  2. Pay for only use
  3. Scales with usage
  4. Availability and Fault tolerance built-in

We just need to focus on business needs and focus our energy on writing the code rather than server setup and scaling the server.

AWS Lambda is serverless compute service. Lambda handles

  1. Load Balancing
  2. Auto Scaling
  3. Handling Failures
  4. Security Isolation
  5. OS Management
  6. Managing Utilization

and many more things for you.

A serverless application has two components. It has

  1. Event Source: It causes triggering of Lambda Function. It has changed in the datacentre, request to endpoints, changes in resource state etc.
  2. Function: In this various programming languages built-in such as node JS, Python, Java, c#, Ruby, Runtime API etc




1.  Click on Create Function in Lamda Service

aws lambda

2. Write Function Name(“Welcome_InfoHubBlog), Select Runtime(I am selecting Node 14.x) and In permission Specify Role Name(InfoHubBlog) and then click Create Function

aws lambda

After this, your lambda function will be created.

aws lambda

Currently, it has only a raw function handler which basically returns status code 200 and “Hello from Lamda!”. To execute, you can click on Test Button and specify the event name and then Create.

exports.handler = async (event) => {
    // TODO implement
    const response = {
        statusCode: 200,
        body: JSON.stringify('Hello from Lambda!'),
    return response;


aws lambda

You can even add API Gateway so that you can get endpoints. For that, you can go to Configuration Tab and the Add Trigger. In Add Trigger you will get Option API Gateway and in API type you need to select REST API and in Security, you can select any but for the tutorial, I have selected Open and then click ADD.


You will get API endPoint and on Hitting API endPoint you will get the result below.

Screenshot 2021 08 16 at 8.51.52 PM


We just set up in a couple of minutes. We didn’t set up the server, didn’t set up Operating System, didn’t set up any load balancing except we just wrote code and deployed on lambda. This was an incredibly basic example. We didn’t talk of any databases, did not do any exciting calculations but again we did a very little amount of work to get this up and running.

Anatomy of Lambda Function

  1. Handlers() function: Function to be invoked upon invocation. It is an entry point.
  2. Event Object: Data Sent during Lambda function Invocation
  3. Context Object:  Methods available to interact with runtime information(request ID, log group, more)

AWS Lambda Architecture


Lambda Execution Model

  1. Synchronous(Push): For this model, we have performed the lab exercise above. We had API Gateway, configure in Lamda function and we made a request to API and the response is sent based on Configuration.
  2. Asynchronous(Event): In this, we take an image file and upload it in S3 Bucket or you put a message in Amazon SNS(Simple Notification Service). That service is going to invoke lambda which will take that message or object information and act upon it.
  3. Poll Based: In this, we have DynamoDB or Kinesis and on the lambda side, we run a poller that is constantly looking for messages and pass the message to the lambda service.

aws lambda

Common Lambda use cases

  1. Web Applications: Static Website, Complex Web App, Packages for flask and Express.
  2. Backends: App & Service, Mobile, IoT
  3. Data Processing: RealTime, Map Reduce, Batch
  4. Chatbots: Powering chatbots logics
  5. Amazon Alexa: Powering voice-enabled apps, Alexa skill kits
  6. IT Automation: Policy engines, Extending AWS Service, Infrastructure Management

AWS Lambda Calculator Pricing

Hope you like our Blog. Please subscribe to InfoHubBlog for daily update.

For Tech Blog: InfoHubBlog Tech

Reference :



Be the first to comment on "AWS Lambda | Serverless | 2021"

Leave a comment

Your email address will not be published.