Is AWS Lambda yet another Platform as a Service?

Its more than 3 years since AWS has introduced Lambda Service back in 2014. So lets ask what is AWS Lambda from Wikipedia.

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

Many people wonder what is so special about Lambda Service since there were many Compute Services available even before Lambda such as Google App Engine, Heroku & etc. One can say, Lamda is Function as a Service(FaaS) not a Platform as a Service (PaaS). Again the same question repeats, what so special about Lambda?

Other Public Clouds, also started providing similar services such as Google Cloud Functions, Azure Functions & etc. and some of the capabilities I discuss here about Lambda are applicable to those as well.

1. Lambda is Event Driven

One of the major differences with Lambda compared to Traditional Platform as a Service is that, its event driven where the code is and its container is not running unless its invoked.

Ok so does that mean upon invocation, it requires to first start the container and then run the code at the same time? Yes and not only that, the underlying container also needs to load the code before execution.

So probably the first question comes to your mind is “Is it fast enough?” The real answer is, it depends.

Although Amazon improved its performance to a reasonable level by reusing Containers for consecutive invocations (Search for AWS Lambda COLD Start and HOT Start), still there are several factors you need to look towards before using Lambda which governs its performance.

  • The size of the code you deploy to a Lambda function.
  • How frequent its invoked.
  • How much memory you allocate to the Lambda function.
  • How long it takes for the Lambda function to execute the code (Depending on the CPU bound and IO bound Logic).

So ideally it is recommended to keep the Lambda code simple (Less size) and allocate reasonable amount of memory (Amazon not only allocates memory upon memory selection, it also matches with CPU performance) for the execution.

If the function is not invoked frequently you can deploy a strategy to keep the Lambda function HOT by invoking within 5 minutes interval and surpassingly it won’t cost you much. There are couple of ways to achieve this.

  • You can configure a Scheduled Lambda to invoke the Lambda with a quick exit path e.g ping event which calls the success callback
  • Schedule a Lambda function with AWS CloudWatch events.
  • Setup AWS Route53 Health Check.

2. Lambda is Everywhere

Another major difference with AWS Lambda compare to a Platform as a Service is its true function nature. You can connect Lambda functions to many services in AWS building rich workflows without the trouble in managing a EC2 instance. You can connect Lambda with S3, SNS, API Gateway, DynamoDB, Kinesis and etc. also allowing to connect different services together.

3. Pay for the Consumption

When using AWS Lambda, you will be paying for only the execution of milliseconds for each function although the pricing for each time block changes depending on the amount of memory you allocate. This vastly different from paying an hourly fee or a fix amount for using a Platform as a Service.

Lambda Pricing Details

The Lambda free tier includes 1M free requests per month and 400,000 GB-seconds of compute time per month.

Requests

You are charged for the total number of requests across all your functions. Lambda counts a request each time it starts executing in response to an event notification or invoke call, including test invokes from the console.

  • First 1 million requests per month are free
  • $0.20 per 1 million requests thereafter ($0.0000002 per request)

Pricing Reference: AWS Lambda Pricing Details Page

This will be really useful in implementing an API using AWS Lambda. Since the number of consumption reduces when newer versions available, this will reduce the cost for consumption for older APIs and naturally ends up to zero when all the consumers migrates to the newer versions.

4. Automatically Scales

The scalability model with Lambda is significantly different from Platform as a Service. Since Lambda function container provisioned upon invocation (When an event is received), it is also possible to scale out when number of events increases.

Q: Is there a limit to the number of AWS Lambda functions I can execute at once?

No. AWS Lambda is designed to run many instances of your functions in parallel. However, AWS Lambda has a default safety throttle for number of concurrent executions per account per region (visit here for info on default safety throttle limits).

Concurrent Execution Limit

By default, AWS Lambda limits the total concurrent executions across all functions within a given region to 1000. For instructions on how to increase that limit.

Scaling Reference: AWS Lambda FAQs

However it is important to understand that Lambda scaling doesn’t work in the same way for different event sources. So do good enough research before designing your solution for scalability.

5. Builtin Fault Tolerance Strategies

Have you ever wonder what will happen, if a Lambda function fails upon execution throwing an Error?

This is one of the important aspects of Lambda where you can externally configure the function to use fallback strategy to send the event payload to SNS or SQS allowing to take further decisions on how to handle the situation after certain number of retries.

Like what you read? Give Ashan Fernando a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.