📜 ⬆️ ⬇️

AWS Lambda and no servers

For me personally, Amazon Web Services has always been associated with Infrastructure as a Service (IaaS), on the basis of which everyone built their services and applications. But there are also competing platforms as a service, for example, Elastic Beanstalk and OpsWorks. Although, in my opinion, they can be considered a PaaS with a stretch, as there remains access to the infrastructure, and at the same time a headache for its administration.

The beauty of PaaS is zero administration costs, ease of use and, as a result, the ability to focus on the application code, forgetting how to deploy, integrate and maintain it.

So, according to AWS representatives, Lambda will let you forget about the infrastructure and run applications in the cloud, while getting integration with other Amazon services, scalability, low cost of using computing resources. All you need to start is to write a function, associate it with events. After that, Amazon will automatically perform the function with each new event. You can not think about scaling and high availability: our function will be able to process tens of thousands of requests per hour without any efforts on our part, without backend in its traditional sense.

')

Concept


The main workhorse is the lambda function (or Lambda expression ). The lambda function is associated with the context:


How it works


When the resource changes, a message is generated that activates the function. In turn, it (the function) has access to a JSON object that contains all the necessary information about this change, or about another message.

For example, we can associate a function with s3-bucket. When a new object enters it, our lambda will be launched and will have access to data about it. Suppose this is a new image for which you want to make a set of sketches of different sizes. Our function will be launched with each new image loaded into the bakt, and we can save the result in the same or a separate bakt.

It must be remembered that our function does not retain its state (stateless), so the results of the work should be stored in any data warehouse. In our example, this is S3 bucket.

Environment


Currently only JavaScript + Node, js is supported. You can also download libraries and use the AWS SDK. As I understand it from the presentation video, a Docker running on the EC2 instance is used under the hood.

Current limitations and future plans


First of all it caught my eye:

Also, as mentioned above, only JavaScript is supported as a programming language.

Plans to expand the list of supported services (now it is S3, DynamoDB and Amazon Kinesis) and increase the number of supported PL.

Price


This service is paid for in two ways: the number of requests and their total execution time, taking into account the memory consumed.

Number of requests



The total duration of the request




As usual, AWS provides a free period (free tier). More information about prices can be found here . There are a few examples. I will bring one of them.
If the function execution time is 1 second, and it will be launched 3 million times within a month, then we will receive a bill of $ 18.34.

Related Links


Official blog
Service start page

PS


AWS Lambda is in the “preview” stage; in order to register and gain access, you need to fill out a request by reference . Given the very good free tier, it's worth a try. If there is time, I will definitely share practical experience of use.

Source: https://habr.com/ru/post/245949/


All Articles