
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:
- Environment: PL, amount of RAM, access settings
- Resources whose changes need to be monitored
- Code is the same function that is executed when a resource change message is received.
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:
- no ready CI / CD
- no integration with version control systems (git, svn)
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
- first million requests per month - for free
- all that is above this limit is $ 0.20 for 1 million requests ($ 0.0000002 for one request)
The total duration of the request
- the start time is counted from the start of the function until the result is returned, or until it stops by timeout (set for each function)
- time is rounded up to the nearest multiple of 100 ms
- the cost of each second depends on the amount of allocated memory, i.e. $ 0.00001667 for each Gigabyte-second
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 blogService start pagePS
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.