fbpx
Search
Close this search box.

Going Serverless: A Walk Through AWS Lambda

illustration of a cloud against an orange gradient background to represent ec2 backup and ebs snapshots
Learn the benefits of using AWS Lambda—like no administrative requirements, monitoring, provisioning, and patching.
Share This Post
walkthough-aws-lambda

Are you looking to run your applications without provisioning servers? AWS Lambda will allow you to do this and more. In this post, we will walk you through both the many benefits as well as the limitations of AWS Lambda. The computing model, also called “serverless” eliminates the need for maintaining infrastructure, so you only need to take care of your code.

Serverless computing is managed by the cloud provider, where applications run in stateless computing containers that are event-driven. It executes user-defined functions that collect data from an outside service, works with the data, and delivers the output to another service. Lambda requires zero administration, with no operational or administrative work to be performed on the user’s end. It offers a great way to execute stateless code in response to events in S3 buckets, messages to SNS topics, and a variety of other S3 lambda triggers.

AWS Lambda even deploys the code on the user’s behalf, in addition to performing various administrative activities like monitoring the health of the application and provisioning the capacity of the instances. With such capabilities, AWS Lambda serves as a great building block for applications. AWS Lambda handles capacity, scaling, deployment, monitoring, logging, and security patching. It even scales the infrastructure to match the rate of events, and the user never needs to worry about over- or under-provisioning. It also helps create new applications without having to consider scaling.

Scripting with AWS Lambda

AWS Lambda functions can be coded through Python, JavaScript, C#, Node.js, or any other JVM language, such as Scala, Closure, and Groovy. The AWS Lambda Console provides an internal online editor that enables developers to run their scripts in conjunction with AWS Lambda’s code functions. Stateless Lambda function can be triggered by events such as a new file in S3, a new row in the DynamoDB, or even HTTP calls. This allows users to create APIs and API Gateways that are scalable and cost-effective. With Function as a Service (or FaaS), applications are event-driven and instantaneously scalable. FaaS provides the ability to deploy a single, maintainable function that is dedicated to the application.

Lambda functions are short-lived, so their state needs to persist in the background. An inbound firewall protects the network against incoming traffic from the internet and is restricted by AWS Lambda. An outbound firewall protects against outgoing traffic inside a network, but AWS Lambda only supports TCP/IP sockets for outbound connections. Functions in Lambda are scripted to fire in response to an event and to run single functions that take a single input and execute complex operations, including auto-provisioning of back-end services and HTTP authentication request events using AWS Cognito. Developers should be aware that writing small functions and performing unit tests is easy, but that integration is difficult and may take longer than expected during deployment. This article explains the entire procedure to create a Lambda function with Node.js.

Scaling and Provisioning in AWS Lambda

Over-provisioning is a burden on enterprises, as resources are wasted while the system remains idle. On the other hand, if the resources are under-provisioned, congestion and latency do not allow the system to function efficiently. AWS Lambda automatically handles the provisioning of resources and simultaneously manages capacity, scaling, and maintenance of the application. It works in coordination with AWS CloudWatch to generate logs with every event that takes place.

Computing capacity is usually over-provisioned, but with FaaS, the provisioning capacity will always be equal to the actual usage. The issues of under- and over-provisioning are non-existent with the help of AWS Lambda. In the past, enterprises were forced to explicitly increase the number of instances during peak hours, but AWS Lambda is able to scale the instances automatically, depending on the number of requests. As a result, fewer manual optimizations are needed. It maintains high computing capacity to serve the application across multiple regions, and ensures that the service is fault-tolerant, robust, and running as intended.

Limitations of AWS Lambda

Although Lambda supports a number of programming and scripting languages, handling errors in Lambda is difficult due to lack of documentation. It is a great building block for scripting, but it cannot serve as a replacement for full-featured backups, recovery, or disaster recovery solutions like N2WS, an enterprise-class backup for Amazon EC2, AWS EBS Volume, and RDS databases. Serverless architectures like Lambda are not able to handle long-lived applications; if the execution time crosses a threshold of five minutes, those applications are aborted.

AWS Lambda also has a concurrent execution limit that exceeds the AWS Lambda functions being invoked simultaneously, which results in an immediate error (429 error code). Lambda functions being invoked asynchronously can absorb reasonable bursts of traffic for approximately 15-30 minutes, after which point all incoming events will be rejected.

Cold start is a major issue for AWS Lambda because the Lambda function takes a significant amount of time to initialize a request. In order to utilize resources, AWS Lambda terminates instances where the function is not running in an active state. In such cases, it takes time to invoke a new instance of the function and the response time is slower than expected. To avoid such scenarios, requests should be sent to the instance frequently.

Despite these flaws, AWS Lambda is an overall suitable scripting tool for event-driven applications. It is highly beneficial to developers since it checks the code and performs a myriad of administrative activities, ensuring good health of the application.

Try N2WS Backup & Recovery for FREE

Next step

The easier way to recover cloud workloads

Allowed us to save over $1 million in the management of AWS EBS snapshots...

N2WS vs AWS Backup

Why chose N2WS over AWS Backup? Find out the critical differences here.

N2WS in comparison to AWS Backup, offers a single console to manage backups across accounts or clouds. Here is a stylized screenshot of the N2WS dashboard.