Serverless: “Pay as You Go”
By: Dr. Maria Seraphina Astriani
Do you want to save money when your server is idle?
Try SERVERLESS!
What is serverless computing?
Serverless computing enables developers to build applications faster by eliminating the need for them to manage infrastructure. With serverless applications, the cloud service provider automatically provisions, scales, and manages the infrastructure required to run the code [1].
Serverless computing is an execution model for the cloud in which a cloud provider dynamically allocates—and then charges the user for—only the compute resources and storage needed to execute a particular piece of code or “pay as you go” [2]. If you do not use serverless, you still must pay for the unused resources.
Resources and Demand
Source: Salma REBAI, Allocation et federation des ressources informatiques dans le Cloud (Resource allocation in Cloud federation)
What is Function-as-a-Service?
Function-as-a-Service (FaaS) is a serverless way to execute modular pieces of code on the edge. FaaS lets developers write and update a piece of code on the fly, which can then be executed in response to an event, such as a user clicking on an element in a web application. This makes it easy to scale code and is a cost-efficient way to implement microservices [3].
Using serverless code like FaaS, web developers can focus on writing application code, while the serverless provider takes care of server allocation and backend services.
Should I use serverless?
These are the four main reasons people switch to serverless [4]:
- it scales with demand automatically
- it significantly reduces server cost (70-90%), because you don’t pay for idle
- it eliminates server maintenance
- it frees up developer resources to take on projects that directly drive business value (versus spending that time on maintenance)
Reasons not to use serverless [5]:
- your workloads are constant
- you fear vendor lock-In
- you need advanced monitoring
- you have long-running functions
- you use an unsupported language
Providers
There are many providers that already support serverless and these are some of them:
- Lambda (Amazon Web Services)
- Azure Functions (Microsoft)
- Google Cloud Functions (Google)
- IBM Cloud Functions (IBM)
Please have a look on the following table to know which one is the most suitable for you [6]:
Features |
Amazon Web Services (AWS) |
Microsoft |
|
IBM |
Serverless Compute Offerings |
Lambda |
Azure Functions |
Google Cloud Functions |
IBM Cloud Functions |
Maximum Functions |
Lambda – Unlimited |
Unlimited |
1000 per |
Unlimited |
Scalability & Availability |
Transparent – |
Automatic |
Automatic |
Automatic |
Languages supported |
§ Lambda – Node.js, Python, Java, C# (.NET) § Lambda@Edge – Node.js 6.10 |
Node.js, C#, |
Node.js |
Binaries in |
Max. execution time |
300 seconds |
300 seconds |
540 seconds |
600 seconds |
Max Code Size |
50 MB compressed |
None |
100 MB |
48 MB |
Monitoring |
Dashbird, |
Azure |
Stackdriver |
IBM Cloud |
Concurrent Executions |
1000 |
10 concurrent |
400 per |
1000 per |
Triggers |
§ Lambda – S3, Kinesis, DynamoDB, Simple Notification, § Lambda@Edge – Functions will automatically trigger against |
Queues, |
Cloud |
Periodic |
Web Editing |
Web Editing |
Provided |
Via Google |
Provided |
Logs |
Via |
Available |
Via CLI and |
Yes |
HTTP |
Must be |
Directly |
Can be |
Yes |
Orchestration |
Via the step |
Via Logic |
No |
Via Rules |
Version Control |
Versioning |
Via GitHub |
Via Google |
No |
Deployments |
.ZIP to S3 or |
Via GitHub, |
Google Cloud |
GitHub, |
Access Management |
IAM roles |
IAM roles |
IAM roles |
IAM roles |
Dependencies |
Deployment |
NuGet, Npm, |
Npm |
NA |
Limits |
§ Lambda – Memory Allocation – 128 MB to 1536 MB Ephemeral disk capacity – § Lambda@Edge – Viewer request and response event limits = 128 |
Azure |
Function |
Memory – min Timeout – 60000 ms to 600000 ms |
Pricing |
§ Lambda – 1M requests for free, after that, $0.20/1M § Lambda@Edge – Request Pricing is $0.60 per 1 million requests |
Azure Event |
2 million $0.0000025/GB-sec $0.0000100/GHz-sec with 200,000 GHz-sec/month for free |
Basic Cloud API Gateway: Free/No Limits |
REFERENCES:
[1] https://azure.microsoft.com/en-us/overview/serverless-computing/
[2] https://www.infoworld.com/article/3406501/what-is-serverless-serverless-computing-explained.html
[3] https://www.cloudflare.com/learning/serverless/glossary/function-as-a-service-faas/
[4] https://www.serverless.com/blog/when-why-not-use-serverless
[5] https://blog.runscope.com/posts/why-you-might-not-need-serverless
[6] https://www.dailyhostnews.com/serverless-computing-comparison-guide-aws-google-ibm-and-microsoft