Tuesday, February 9

The Real Pay As You Go - AWS Lambda

My Serverless Computing post received queries about AWS Lambda and microservices.  AWS Lambda  is not microservice but you can create Microservices using AWS Lambda function and API Gateway that would trigger the function (if you are familiar with AWS services). Anyway for now lets understand AWS Lambda

What is AWS Lambda?

AWS Lambda is  famous in serverless world. Amazon Web Services did not invent serverless but their Lambda service has popularized concept of Serverless Computing. So whats AWS Lambda?

AWS Lambda is an event-driven, serverless computing platform provided by Amazon as a part of Amazon Web Services. It is a computing service that runs code in response to events and automatically manages the computing resources required by that code. It was introduced in November 2014.

A simple case for AWS Lambda

  • Take example of a website hosted on AWS EC2  with auto scaling enabled
  • The website is accessed by 100 concurrent users
  • At 12pm PST the administrator starts to uploads 100 videos to the server or starts a batch job for processing. 
  • This increases the load on the EC2 server, and triggers the auto-scaling feature, EC2 provisions more number of instances to meet this requirement. 
  • From triggering auto-scaling to provision more instances takes X milliseconds duration which eventually results in slow actions on the website when the initial spike in the task is received. 
  • This problem of slow response can be solved using distributed computing and allocating dedicated instance for website and 2nd dedicated EC2 for running the back-end code. 
  • When the users are reading blog on the website & the back-end job is running in parallel the performance is not affected. However, video processing still takes a lot of time, as the load increases, because auto-scaling takes comparatively more time on EC2.
  • A better solution is a stateless system called AWS Lambda

AWS Lambda Features

AWS Lambda computing services is event-driven & can be triggered by an message or email 

AWS Lambda computing services is serverless

AWS Lambda is stateless & runs process as background tasks in most efficient manner.

AWS Lambda Components

AWS Lambda is one of the computing services provided by AWS, which is event-driven and serverless. It is a stateless serverless system that helps us run our background tasks in the most

  • Lambda function: Whatever custom codes and libraries that we create are called a function.
  • Event source: Any AWS or custom service that triggers our function and helps in executing its logic
  • Log streams: Lambda monitors each function and its metric can be viewed on CloudWatch, Developer can code our function in a way that it provides us custom logging statements to let us analyze the flow of execution and performance of each function.

 

AWS Lambda Working

 AWS Lambda

 

AWS Lambda Key Benefits

  • No need for provisioning server - Due to its serverless architecture
  • No need to set up any virtual machine (VM)
  • Distributed Event Driven computing and highly scalable service allows developers to run and execute codes in response to events
  • Cost Benefits of - just pay for the compute time taken and only when the code runs. Also, pay only for the used memory and the number of processed code requests, and the code execution time is rounded up by 100 milliseconds.
  • Allows code performance monitoring in real time through Cloud Watch

AWS Lambda Limitations

By design AWS Lambda is not for long running tasks and it has few limitations & drawback

  • The maximum execution duration per request is set to 300 seconds
  • The maximum disk space provided is 512 MB for the runtime environment
  • Memory volume varies from 128 MB to 1,536 MB
  • Event request body cannot exceed more than 128 KB
  • Code execution timeout is only 5 minutes
  • Lambda functions write their logs only to CloudWatch, which is the only tool available  to monitor or troubleshoot our functions


 

No comments:

Post a Comment

Understanding Generative AI and Generative AI Platform leaders

We are hearing a lot about power of Generative AI. Generative AI is a vertical of AI that  holds the power to #Create content, artwork, code...