Monday, 3rd of Jun 2019
Serverless
Cost of going Serverless
When working with serverless instead of traditional bare-metal or virtual machines, such as EC2, there can be substantial cost savings, and it's just not limited to the infrastructure.
Virtual machines are charged on an allocation or instance basis. If the machine is reserved, running or powered off, the fee-clock is ticking, regardless of how utilised the server is. Running at 10% capacity or running hot at 99% capacity, the charge is same.
Serverless on the other hand is pay-per-use. When it's not being used there is usually no charge, once when invoked it's charged.
A fairly simple SaaS environment could be architecture similar to the example discussed in the previous article.
Using a familiar cloud provider, AWS, the system could consist of a couple of EC2 instances, a load balancer, relational database and a storage bucket.
This environment wouldn't cost a huge sum to run, a few hundred AUD each month. As the environment is made up of traditional components, regardless of the usage the fee would remain the same.
Without putting the system under too much stress, an expected usage pattern could show high usage during business hours, and decreased usage over the weekends and overnight.
During peak times the load balancer would be distributing traffic between both servers, letting them both run at around 90% utilisation which should allow users to experience minimal latency.
Without prior configuration both instances would be running 24 hours a day, 7 days a week. This means when the sites aren't receiving traffic they are still costing money to run and sit idle. All those troughs throughout the weekend and overnight are still charged.
The most interesting thing about this usage pattern is the idle running time, and the active compute time are equal. Both account for 50% usage during the week. Which means half of the cloud bill would be for idle time. Take note of the blue area, this is idle time. On average the EC2 instances are both running at half capacity. However, the charge would still for the full EC2 instances.
What a waste of resources and expenditure.
How is serverless architecture different?
There is no need for a load balancer as you could serve a static frontend website built with a modern framework, such as React, straight from an S3 bucket. The frontend framework would tie together API requests to Lambda to complete any business logic or database read & write queries.
This setup with millions of requests per month would cost under a hundred AUD per month - an immediate saving of 60% per month. It doesn’t matter if you get traffic 24/7 or if it comes in waves, the cost will be fully dependant on the amount of traffic the site receives.
It's daunting to look down the barrel of migrating from traditional builds to a serverless build to save resources and get the performance benefits. The Hybrid-Serverless could be the answer, keep an eye out for a case-study to follow of a client that migrated to a Hybrid-Serverless model to manage peak load.
You may also like
3 minute read
Monolithic Serverless Hybrid
Serverless technologies can be plugged into a traditional legacy monolithic platform with little effort, and produce powerful results…
GCP
2 minute read
Monolithic Serverless Deployments
Building on the previous article about the building of the Monolithic Serverless Hybrid, we wanted to discuss how we handled deployments. We…
GCP
4 minute read
What is Serverless
Serverless isn't going away and more companies are starting to use it and more providers are growing their serverless offerings. So what…