AWS Lambda has been pivotal in the shift toward mass adoption of “serverless” architectures. While Lambda is an AWS service, its exploding popularity among AWS users since its initial release in 2014 has set a precedent among other cloud platforms for how businesses run code in cloud.
Given that Lambda is a core building block for serverless applications in AWS, let’s put AWS Lambda in the spotlight for a high-level overview.
What is AWS Lambda?
AWS Lambda is a computing service that is serverless and event-driven. It allows you to upload your code and configure when your application should invoke and execute a function. When you’re running code on AWS Lambda, this is referred to as a Lambda function.
Let’s break down what we mean by “serverless” and “event-driven.”
What is serverless computing?
When AWS Lambda was launched in 2014, it set a new precedent. By offering a fully managed FaaS, or function-as-a-service, whereby your application runs and scales on demand, Lambda defined serverless as we know it today.
The serverless aspect means that the servers required for your application are not your responsibility. With AWS Lambda, you can run code without having to worry about provisioning or managing servers. It lets you focus on your functions—namely, on what your application actually does—while relying on AWS to manage your infrastructure.
What is event-driven code?
Event-driven programming simply means that the code is written so that it responds to some kind of user action, request, input, or other occurrence.
It could be that the user clicked on a button in a mobile app (like uploading a user profile picture), and now the application needs to respond appropriately by turning that uploaded image into a thumbnail.
Or it could be a gamer’s progression in an online video game, where an “event” consists of the user reaching a certain milestone, and the application then unlocks a new tier of premium perks for the user. Or it could be a user’s interaction with in-app purchases, where clicking “Buy now” triggers a financial transaction on the back end, converts real dollars into virtual gaming tokens, and populates the user account with the in-app currency.
The possibilities for creating custom-tailored in-app experiences are limitless. Not just for entertainment applications, but for business-critical customer applications in fintech, health care, eLearning, and more.
How does AWS Lambda work?
As AWS states, “Lambda runs your code on high availability compute infrastructure and performs all the administration of your compute resources. This includes server and operating system maintenance, capacity provisioning and automatic scaling, code and security patch deployment, and code monitoring and logging.”
In other words, bring your own code and AWS will do the rest.
With AWS Lambda, you can upload this code to Lambda as a .zip file or container image. But you can also build your code directly in the Lambda console.
Lambda will automatically run your code in response to events such as:
- HTTP requests via Amazon API Gateway
- Objects that are modified in Amazon S3 buckets, which is Amazon’s Simple Storage Services
- Updates to Amazon DynamoDB (database) tables
- State transitions in AWS Step Functions—which is an AWS tool that allows you to orchestrate event-driven workflows involving various units of work inside AWS, including AWS Lambda functions.
You can use Lambda to get more out of your existing AWS services by applying compute to your data. This is key to creating machine-learning enabled applications.
Lambda is versatile. It can easily be part of your AWS toolkit when designing and managing multi-tier architectures. It can serve as the “logic tier”—code that’s “required to translate user actions to application functionality”—to implement architecture patterns using API Gateway. Lambda-based logic tiers include but are not limited to mobile backends, single-page applications, and web applications.
But Lambda is also instrumental in microservices architectures, which involves decoupling the components into stateless, separate units that communicate with each other.
What program languages does Lambda support?
One of the neat things about AWS Lambda is that your developers don’t need to learn new programming languages, tools, or frameworks.
According to Datadog’s 2022 “State of Serverless” report, Python and Node.js seem to be the most popular programming languages among AWS Lambda users. But AWS certainly supports other programming languages as well.
Currently, Lambda supports these languages:
What are the advantages of AWS Lambda?
Beyond handling your infrastructure needs automatically, AWS Lambda is popular for the following advantages and benefits:
- Happy devs, happy life: Lambda is developer-friendly and lets them write code in smaller chunks. By virtue of taking infrastructure provision out of your end of the equation, it allows you to focus on the quality of your application. And that’s important because your application is the most direct way you provide tangible value to your users and customers.
- Faster time to market: Lambda allows you to build applications and integrate services in a way that works with today’s Agile environment, where users expect fast and frequent feature releases and updates. Again, it allows you to listen to your users and develop accordingly, at scale.
- Quality control: Who says you can’t have speed and quality? Lambda’s “Code Signing” features mean you have trust and integrity controls over your code and functions. Publish and deploy only approved code by approved developers.
- Get built-in fault tolerance: With AWS Lambda you are protected against individual machine or data centre facility failures, and you don’t have to deal with maintenance windows or scheduled downtimes. Lambda boasts “predictable and reliable operational performance.”
- Comply with security requirements: SOC-, HIPAA-, PCI-, and ISO-compliant, Lambda is designed with security in mind. Your Lambda function or layer is encrypted at rest and in transit. It integrates with AWS’s Identity and Access Management (IAM). Amazon’s Security Overview of AWS Lambda documentation explains Lambda’s security features (e.g., how to manage access to functions) and all the ways it can integrate with your own security practices.
- Get billed only for what you use: If your code doesn’t run, you don’t pay. Pricing for Lambda usage is calculated per millisecond, so your billing is granular according to your usage, not arbitrary pricing tiers. This is an added cost benefit to your already reduced operational and administrative overhead in choosing to go “serverless.” We should also note that Lambda offers a free tier that includes 1 million free requests per month and 400,000 GB-seconds of compute time per month.
- Use it in conjunction with other operational tools: While Lambda helps you get the most out of the AWS suite of cloud tools, it is designed to be flexible. In fact, you can integrate it with your favourite monitoring, observability, governance, and security tools on the market. This is possible thanks to AWS Lambda Extensions.
There are more advantages we could mention, especially once you realise that use cases are so open-ended; the above are just several high-level benefits.
What are the limitations or drawbacks of AWS Lambda?
Obviously, Lambda integrates tightly with the rest of the services in the AWS suite. So the moment we start discussing vendor-lock-in concerns in a general sense, Lambda, being the FaaS inside AWS, is implicated as well.
On a deeper level, some have argued that even though importing code is easy, that doesn’t mean it will be “portable across other computing platforms.” Certainly, if we hypothesise how companies might need to overhaul their workloads down the road, we can go down rabbit holes listing limitations.
However, the most important limitation to note is technical in nature: Lambda is not designed for long-running workloads.
Make sure you understand Lambda’s runtime environment limitations (such as disk space, default deployment package size, memory range, max execution timeout) and request limitations (i.e., request and response body payload size, event request body size). Consult the AWS Lambda Developer Guide for information on quotas.
In AWS’s own words, “Lambda is one of the many important services that is offered by AWS today. Lambda is used by hundreds of thousands of Amazon Web Services (AWS) customers to serve trillions of requests every month.”
It is suitable for mission-critical applications across many industry verticals. Whether you’re running a media & entertainment company, a financial institution, a mobile communications company, a real estate listing service, or even a university, if your users access services via a web or mobile application, Lambda can help you “decrease time to market, optimise costs, and improve agility by focusing on what [you] do best: running [your] business.”
How can I learn more?
This article is a part of a greater series centred around the technologies and themes found within the first edition of the TechRadar by Devoteam . To read further into these topics, please download TechRadar by Devoteam .