📜 ⬆️ ⬇️

The dark side of the serverless architecture or the complexity of estimating the real cost of serverless computing

Disclaimer: This article is based, among other things, on the personal opinion of Amiram Shachar (CEO of Spotinst). The author's company offers a competing product called Spotinst Functions.

Translation is made by the cloud provider Cloud4Y . We offer software-configured data centers (vDC) based on VMware vSphere cluster solutions managed by the VMware vCloud Director self-service portal.
According to many experts, serverless computing is the next step in the evolution of computing systems architecture. The reasons for making this “jump” are clear:


Serverless - the next step
')
As a transition from on-premises to the cloud, the transition to serverless is to some extent inevitable. However, having made this move, you may unexpectedly get a bill for a larger than expected amount.

The cost of serverless computing is more than pay-per-trigger


TimerCheck.io is a service built entirely on AWS Lambda and API Gateway by Eric Hammond (Eric Hammond, SVP Technology at CampusExplorer).

When working on AWS Lambda, the costs of the TimerCheck feature were incredibly low — only $ 0.22 for 2 million requests and 300,000+ seconds of calculations. Sounds much more profitable situation with the payment for the entire server when using only part of it, is not it?

So, but the fact is that the Lambda functions accounted for slightly less than 2% of its total AWS cloud value.



After that, Eric wrote an AWS Lambda pricing article calling on Amazon to lower the cost of the API gateway.
“If you are reading this post after November 2016, the prices for these AWS services have certainly changed, and you should not use any of the above calculations when making decisions about working with AWS,” said Eric.

But, in fact, prices have not changed.

What are the real costs of serverless computing?


In fact, the cost of serverless is more than just the cost of CPU and RAM, and for many users the main cost factors will be additional cost categories such as API Requests, Storage and Networking.


5 cost categories for serverless

Visible costs



Hidden costs




Unknown costs beforehand


Some of the cost of serverless is not always easy to measure in dollars and cents.

Support code
Serverless coding = more lines of code. So Twin Tech Innovations noted: "For each non-trivial query processing route (part of the functionality) added to the program, the number of lines of configuration code needed to support the project grows with transcendental linear speed when using serverless architecture."


Line Code Comparison

“Someone should support all this. Someone must ensure that there will be no problems, that changes are made to the configuration of only one function and will not be accidentally transferred to others. Someone has to make sure that the code is not duplicated, and the complexity and dependencies are manageable. ”

Cold boot
Without going into details, it is worth noting that the initial launch is the main reason why some companies decided to abandon serverless when evaluating Lambda .

“100 milliseconds just to run ... while the user application needs a latency of less than fifty milliseconds,” said Hannah Taub.

These initial startup delays are likely to disappear in the end, but for now you have to take them into account.

How to analyze the cost of serverless architecture


Now we will carry out a cost analysis based on the basic components. Each of them has enough details for much deeper calculations, but we limit ourselves to this.

Consider the main differences in prices.
The AWS Lambda feature with 512 MB of memory costs $ 0.030024. On-Demand server comparable in characteristics will cost from $ 0.0059. Therefore, if the processor is fully used all the time, work on the serverless architecture may be less efficient for such a workload.

Properly design API requests
API Gateway tends to be a significant part of your costs if you connect to a large number of APIs. The more API requests you make per trigger, the less savings you will see from switching to serverless.

Do not forget about traffic
The transition may be inappropriate if data / networking creates the bulk of the cost of the application.

Explore the offers of all serverless providers
There are several alternative offers on the market, each of which has its own unique advantages in pricing.


Cost comparison

Estimate the cost of additional support code
Think about how much time you or your team will have to spend on switching to serverless calculations.

Free tier
Almost every provider offers a level of free use, sometimes it is enough to run small workloads. If you want to be super economical, you can use them all together. If you design your serverless applications properly, this can be an excellent opportunity to gain independence from the provider. In addition to cost savings, it will also allow you to run functions with cloud providers that are most suitable for this particular workload.


Comparing Free Tiers

Ultimately, the transition to serverless architecture can provide great potential in terms of cost and time savings. To avoid any surprises, it is worth spending time analyzing before fully diving into serverless.

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


All Articles