Introduction to Serverless Computing:

Serverless computing is also referred to as Function as a Service (FAAS).

Serverless Computing is an execution model provided by cloud service providers, where the end-user does not need to worry about the cases of managing and maintaining the servers.

Protect Your Data with BDRSuite

Cost-Effective Backup Solution for VMs, Servers, Endpoints, Cloud VMs & SaaS applications. Supports On-Premise, Remote, Hybrid and Cloud Backup, including Disaster Recovery, Ransomware Defense & more!

Serverless applications are deployed in containers that are automatically launched on demand. Such Computing methods offer more scalability, flexibility and reduces usage cost.

Some of the well-known serverless services are

  • AWS Lambda
  • Microsoft Azure Functions
  • Google Cloud Functions
  • Apache OpenWhisk, etc

In this post, we will discuss AWS Lambda in detail. Here are the things we will cover in this article:

Download Banner
  • What is AWS Lambda
  • Components of AWS Lambda
  • Triggers that invoke Lambda functions
  • EC2 vs Lambda
  • AWS Lambda Use Cases, Pricing, and more

What is AWS Lambda?

Lambda is one of the technologies of AWS for running code, managing data, and integrating applications, without the need of managing the servers. The only thing that the user needs to do is create lambda functions and deploy their code in the AWS infrastructure.

AWS Lambda takes the code and runs it on a high- availability compute infrastructure

In lambda, each function has its own configuration information, such as its name, description, entry point, and resource requirements.

When we provide the code to be run on the lambda, first a container will be created on its own and deployed, and the code will be run inside the container. We practically don’t have any control over the infrastructure created/managed for deploying the lambda code. AWS Lambda can be integrated with other AWS services easily.

Basic Workflow:

  • Developer writes and uploads code to AWS lambda functions
  • Event source specified will trigger the functions
  • AWS Lambda will create a temporary container
  • Lambda runs the code when triggered
  • Container is automatically destroyed when the task is completed

Components of AWS Lambda:

  • An Event Source: Triggers the function
  • A Function: The actual user’s code
  • A Configuration: Specifies how the program is executed

AWS Lambda

Triggers that invoke AWS Lambda:

  • Lambda is a function that is executed by queries from triggers
  • An event source/trigger can be uploading a file to the Amazon S3 bucket, making changes in DynamoDB tables, getting an HTTP request to the API Gateway service, etc. Once you’ve set up a function to run when an event occurs, your application will be launched automatically for each new event
  • Below mentioned are a few examples of triggers:
    • API Gateway,
    • AWS IOT,
    • S3,
    • DynamoDB,
    • SNS ,etc,..

Lambda Code Storage:

  • Lambda uses Amazon S3 to provide storage where the codes are stored
  • Each function of AWS Lambda function memory allocation can take from 128MB to 10,240 MB
  • Storage for lambda functions is allowed up to 75GB per region and can be extended
  • Each Lambda function can use upto 512 MB to 10240 MB in 1 MB increments, storage will be available in the lambda function’s /temp directory

Code Deployment:

  • Users using Node.js or Python can author the code for their function using code editor in the AWS Lambda console, which lets the author test their functions, and view the results of function executions in a robust IDE
  • Users can also package the code of any dependent libraries as a ZIP and upload it using the AWS Lambda console from their local environment or specify an Amazon S3 location where the ZIP file is located
  • Uploads must be no larger than 50MB even as a compressed file. Users can use the AWS Eclipse plugin to author and deploy Lambda functions in Java. They can also use the Visual Studio plugin to author and deploy Lambda functions in C#, and Node.js
  • Any piece of code (including frameworks, SDKs, libraries, and more) can be packaged as a lambda layer for simple management and sharing across several functions

Programming Language Support:

  • AWS Lambda supports multiple programming languages including Go, Python, Java, C#, Ruby, PowerShell, and Node.js, and also provides runtime APIs which allows you to use any additional programming languages to author your functions
  • A sample implementation of python code in lambda function is given below in the following link, https://docs.aws.amazon.com/lambda/latest/dg/python-package.html

Lambda Pricing:

  • You only pay for the number of times the function is invoked and the time needed to finish execution
  • The price for each second of running an application depends on the amount of memory provisioned for an application and is $0.00001667 per Gigabyte-second ( varies based on region )
  • The time of application execution is counted from the application’s start to the return of the result or to stop after a timeout

For more information, refer https://aws.amazon.com/lambda/pricing/

EC2 vs Lambda:

  • In AWS Lambda, Users provide only the code; the remaining aspects are handled by AWS whereas in EC2, users have to manage all aspects ( In terms of resources management)
  • Lambda functions don’t require security updates and patches. Underlying containers and operating systems are updated automatically by Amazon. This is the advantage of using Lambda functions in terms of security whereas EC2 requires
  • Runtime is limited to lambda whereas in EC2 instances are always available to run .long running tasks are not suitable for Lambda
  • Compared to lambda, EC2 is more flexible
  • Scalability is a major advantage of Lambda, whereas, in EC2, we have to manually configure scalability features..
  • If there is a lot of idle time in your application on an EC2 instance that is always running, consider using AWS Lambda with which you don’t need to pay for idle time if there are no requests to run an application

AWS Lambda

Sample Use Cases of Lambda:

  • Automating tasks in event of any action like processing objects as soon as the file is uploaded to Amazon S3
  • Real-time log analysis
  • Mobile applications – on-click events can trigger lambda functions

Why to use AWS Lambda?

  • No servers to manage and maintain
  • Easy to use and deploy
  • Millisecond metering, you are charged for your usage in milliseconds
  • Modernize your application
  • Automatic scaling
  • Cost reduction by avoiding deployment of ec2 resources

Drawbacks:

  • Latency occurs when a function is not executed for a durable period of time. Every time a function is invoked, a temporary container is created and after the function is completed, the container is destroyed. Next time the same Lambda function is called, container has to be created again, which will delay the execution
  • Using AWS Lambda for running applications may be a good solution only when you have uneven workloads, and applications will run in different periods of the day with long pauses between application executions
  • Debugging lambda functions can be hard in several cases
  • The running period of lambda has been limited to 15 minutes
  • Lambda has limited memory for uploading codes and packages

Follow our Twitter and Facebook feeds for new releases, updates, insightful posts and more.

4.5/5 - (2 votes)