What Is AWS Lambda?
Lambda lets you run code without provisioning or managing servers, AWS states on the Lambda product page. You can think of Lambda as an event-driven computing platform; Lambda runs when triggered by an event and executes code that’s been loaded into the system.
Recently, Lambda has become popular thanks to AWS, but many folks still use Lambda and serverless interchangeably. In this post, we are going to shed some light on AWS Lambda, including how it ties into serverless architecture, how to create it, and when to use it.
Describing AWS Lambda
AWS Lambda service is a high-scale, provision-free serverless compute offering based on functions. It is used only for the compute layer of a serverless application. The purpose of AWS Lambda is to build event-driven applications that can be triggered by several events in AWS.
In the case where you have multiple simultaneous events, Lambda simply spins up multiple copies of the function to handle the events. In other words, Lambda can be described as a type of function as a service (FaaS). Three components comprise AWS Lambda:
A function:- This is the actual code that
performs the task.
A configuration:- This specifies how your
function is executed.
An event source (optional):- This is the
event that triggers the function. You can trigger
with several AWS services or a third-party
service.
Lambda Function
Finally here is what a Lambda function using Node.js looks like.
Here myHandler is the name of our Lambda function. The event object contains all the information about the event that triggered this Lambda. In the case of an HTTP request it’ll be information about the specific HTTP request. The context object contains info about the runtime our Lambda function is executing in. After we do all the work inside our Lambda function, we simply call the callback function with the results (or the error) and AWS will respond to the HTTP request with it.
Conclusion
AWS Lambda is like a magic tool by Amazon. It helps run computer code without dealing with servers. It's part of something called serverless, which means you don't have to worry about setting up servers or other technical stuff. It's great for making applications work smoothly without any headaches about server management. Developers use it for building cool things that respond to events.