This comprehensive guide covers AWS Lambda, an on-demand serverless computing service. Learn how Lambda complements other AWS services, and how your business can use it.
The original pitch for cloud computing is the ability to scale computing power to the needs and growth of your organization–without provisioning the physical hardware in advance, or dealing with the corresponding lifecycle tasks of installation, hardware maintenance, and eventual decommissioning. “Serverless” computing services, foremost among which is AWS Lambda, are the logical next step in the “as a service” model of delivering computing resources. (Note: This article about AWS Lambda is also available as a free PDF download.)
This TechRepublic primer on AWS Lambda is an introduction to the serverless computing framework. The article will be revised periodically to reflect the latest updates and integrations.
What is AWS Lambda?
AWS Lambda is the serverless computing component of the AWS catalog, enabling developers to execute arbitrary code on demand, without the need to provision or manage a “full” server, or a computing instance like Amazon EC2. After being triggered, AWS Lambda tasks are typically executed within milliseconds. In an AWS Lambda operation, processing time is limited to 300 seconds, with usage billing rounded to the nearest millisecond.
As with any other cloud computing service, billing reflects the amount of computing resources actually used–if no task is being executed, there is no charge.
What are the benefits of using AWS Lambda?
Smart deployment of AWS Lambda for your application workflows can increase the performance of existing infrastructure in your organization as tasks are offloaded onto Lambda functions. AWS Lambda functions execute on demand when invoked by an application, allowing for highly variable self-managing workloads beyond what cloud-hosted virtual machine (VM) lifecycle management rules can achieve in terms of performance. By engineering applications to rely on serverless functions, developers can decrease the cost of cloud deployments in use cases where variable workloads in EC2 can be offloaded to Lambda, decreasing underutilized high-capacity instances.
SEE: Cloud computing policy (TechRepublic Premium)
AWS Lambda is useful for handling cloud-facing processes with various types of data. For example, in a photo-sharing website, AWS Lambda can be invoked to resize images for thumbnails when a photo is added to an Amazon S3 bucket. An AWS Lambda operation can be triggered in response to any API call in AWS.
AWS Lambda natively supports Java, Go, PowerShell, Node.js, C#, Python, and Ruby code, with an additional Runtime API allowing for more programming languages. Because of the 100ms billing unit size of Lambda, using languages like Java with additional overhead to start execution is not recommended. AWS Lambda can be used to invoke any arbitrary process supported in Amazon Linux.
Relative to cloud-hosted VMs like EC2, maintenance time and operational costs are the responsibility of the platform operator. Tasks like server provisioning, installing and configuring operating systems, managing associated licenses, and deploying load balancers are not considerations for serverless platforms including AWS Lambda.
Because of this, Ory Segal, CTO at serverless security firm PureSec, notes that “using AWS Lambda will be cheaper by about 3 to 10 times compared to traditional VM/container-based services such as EC2; however, this only applies to certain types of workloads. In the worst case, AWS Lambda can be comparable to EC2 costs or slightly more expensive. It really boils down to how AWS Lambda is being used. Organizations should carefully assess the types of workloads they need to run, and pick the compute option that makes the most sense.”
How is developing for AWS Lambda different than other cloud services?
Serverless computing is a significant architectural departure from cloud-hosted virtual machines, like EC2. For virtual machines, pipelining tasks to run serially makes sense to prevent a single task worker from monopolizing the computing power of the VM. For serverless platforms like AWS Lambda, parallelism is key to performance and cost savings.
According to Segal, “there are certain ‘actions’ that could easily be reused across executions,” including “connections to cloud resources such as databases, persistent network connections and so forth. If you re-use resources and connections intelligently, they will only occur once, during cold-start, saving you precious compute time.”
Segal continues that, “You should strive to design your application in a way that will run multiple smaller functions in parallel,” and allocate adequate amounts of memory to functions, as “higher memory allocation can reduce the overall compute time dramatically.”
The “time is money” aspect in hourly billing of EC2 is a more pressing concern with AWS Lambda, which is billed in units of 100ms. Developing applications with a serverless-first mindset is paramount to effectively utilizing Lambda; you should also be mindful that reducing resource consumption will stretch budgets significantly.
Security practices for AWS Lambda and other serverless computing platforms are discretely different from traditional methods. The variety of event sources that an AWS Lambda function can handle increase the attack surface. Segal notes “security-monitoring serverless architectures is still more complicated than standard software environments, leading to blind spots for organizations that don’t use serverless-native security solutions,” and “automated scanning tools are currently not adapted to examining serverless applications.”
Who does AWS Lambda affect?
Developers can leverage serverless computing platforms like AWS Lambda to create applications that scale as needed for increasing or variable workloads; this scalability can be used to effectively decrease the operating cost of the app for enterprise usage.
While the use of traditional cloud services typically reduces the need for on-premises servers to be managed, lightening the workload of data center managers, the use of AWS Lambda would lighten the load of operations managers tasked with ensuring the proper operation of VMs hosted on traditional cloud services.
Nominally, the use of serverless computing platforms should be transparent to end users of applications that utilize them. The on-demand scalability of AWS Lambda is more responsive than the threshold scaling common to VMs and the relatively fixed capacity of on-premises server deployments; utilized efficiently, this results in decreased potential for downtime under heavy load.
When was AWS Lambda launched?
AWS Lambda was launched in November 2014 at the annual AWS re:Invent conference. Real-world deployments have increased recently as developers become more familiar with the platform. Amazon touts VidRoll, Localytics, MLB Advanced Media, The Washington Post, and Zillow in case studies as early adopters of AWS Lambda.
Since its 2014 launch, Lambda has changed in a number of ways. Most recently, at re:Invent 2020, Amazon announced changes to billing that reduce usage costs from the nearest 100 milliseconds to the nearest single millisecond, support for Lambda container images up to 10 GB in size, and the general release of the CloudWatch Lambda Insights dashboard.
Which services compete with AWS Lambda?
AWS Lambda was the first serverless or event-driven computing product of public cloud providers. As a consequence of that first-mover position, AWS Lambda provides the most complete and mature platform, with a larger ecosystem of third-party integrations than other providers.
Microsoft’s Azure Functions service is a direct competitor to AWS Lambda. Additionally, Azure Service Fabric provides the ability to separate Azure applications into microservices, which can be invoked and maintained separately from the underlying infrastructure. This functions as a somewhat abstract combination of Docker-style containers and serverless computing services like AWS Lambda.
There’s also an open-source alternative to Lambda: Apache OpenWhisk. OpenWhisk is described as being able to be deployed anywhere, accepting of code in various popular languages, scalable, and easy to integrate with other services thanks to its ability to package functions.
How do I get AWS Lambda?
Anyone with an Amazon account can sign up for AWS, which includes access to AWS Lambda. In the AWS Free Tier, you receive a monthly allotment of 1 million free requests and up to 3.2 million seconds of compute time per month. Unlike other services in the AWS Free Tier, AWS Lambda access does not expire after one year. Pricing for Lambda is determined by the amount of RAM dedicated to each request, with billing in units of 1ms.
For startups, the Activate program offers AWS credits for approved new businesses in two different tiers. The Founders package offers $1,000 in promotional AWS credit for up to two years and $350 in AWS developer support credits, whereas the Portfolio package provides up to $100,000 of promotional credit for AWS, up to $10,000 USD in AWS Business Support credits, 80 credits for Qwiklabs, and “access to exclusive members-only offers.”
AWS Activate requires an application, and there’s no guarantee of approval. For startup businesses interested in Lambda or any other AWS services Activate is definitely worth the time it takes to fill out an application, which Amazon said only takes a few minutes.