AWS Lambda
AWS Lambda can be described as a type of "serverless function as a service" (FaaS). FaaS is one of the approaches in building event-driven computing systems. It is based on functions as units of placement and execution. Serverless FaaS is a type of FaaS where neither virtual machines nor containers are present in the programming model and where the provider provides free and built-in reliability.
AWS Lambda - introduction
AWS Lambda is a serverless service that provides function-based calculations. Provides a logical cloud layer for your application. Lambda functions can be called by various types of events that occur in Amazon Web Services or in external services. They enable the creation of reactive event-driven systems. At a time when there are many simultaneous events to be answered, AWS Lambda easily runs more copies of functions in parallel. Lambda functions scale precisely, along with the size of the load, up to an individual request. Hence, the probability of having an idle server is very low. Architectures that use AWS Lambda features are designed to reduce wasted capacity.
AWS Lambda runs the specified code. This can be code created in any language supported by AWS Lambda (Java, Node, js. Python or C#). You can easily move libraries, artifacts, or compiled native binaries that can run at runtime as part of a function code package. You can even run code written in another programming language (PHP, Go, SmallTalk, Ruby, etc.) as long as it is prepared and recalled from one of the languages supported by the AWS Lambda runtime. The AWS Lambda runtime is based on Amazon Linux AMI.
With Lambda, you can run code for virtually any type of application or backend service. Lambda supports and scales code with high availability. Each Lambda function you create contains code that can be executed, a configuration that defines how the code is executed, and optionally one or more event sources that detect events and call the function when they occur. An example event source is API Gateway, which can call the Lambda function whenever an API method created from api Gateway receives an HTTPS request. Another example is Amazon SNS, which has the ability to call the Lambda function every time a new message is published in the SNS subject.
Additionally, AWS Lambda also provides an API RESTful service that includes the ability to call lambda functions directly. You can use the API to execute code directly without configuring another event source.
You don't need to write any code to integrate an event source with AWS Lambda, manage any infrastructure that detects events and delivers them to the function, or manage the scaling of AWS Lambda to match the number of events delivered. Thanks to this, you can focus on the logic of the application and configure the sources of events that cause the logic to run.
Diagram of AWS Lambda operation:
Advantages of AWS Lambda
The most important advantages of AWS Lambda include:
- no need to manage a server – you don't have to supply or maintain any servers. There is no software or runtime to install, maintain or manage;
- elastic scaling – you can scale the application automatically;
- high availability – serverless applications such as AWS Lambda have built-in availability and error tolerance. You don't need to oversee these performances because the services that support the app provide them by default;
- no unused production capacity – you do not have to pay for unused production capacity. There is also no need for preliminary planning or the creation of back-up capacitive blocks for calculation or storage. There is no additional charge if the code is not running.
How much does AWS Lambda actually cost?
One of the most important advantages of AWS Lambda is its billing model. AWS Lambda operates in the Pay-as-you-go model. What does this actually mean? That we pay only for what we use. In this case, it is about the number of function requests and their duration, i.e. the unit of time in which our function is performed. Interestingly, the "free tier" of AWS Lambda includes 1 million requests per month and 400,000 GB-seconds of computing time per month. The specific price for duration depends on the amount of memory allocated to the function. Details about the AWS Lambda price list: https://aws.amazon.com/lambda/pricing/