Serverless Computing powers up your application backend with zero configuration of servers running on the cloud while focusing you more on business logic rather than server management. All you need to do is how you write code and just deploy it on the cloud(AWS Lambda for Compute).
Let’s just take a scenario, you have a pretty website and you don’t know much traffic going to hit.
1.) In the first part here you can see that the traditional way to set up your infrastructure. Here you own the datacenter, all servers, spending monthly bills for managing those servers, electricity, AC, etc.
If we consider the Scenario in the 1st part, you addon more servers to accommodate the huge traffic, but the question arises, what would happen if the traffic goes down or in average rate, therefore, your addon servers are then sitting idle. you can’t sell after purchasing those servers. That’s funny, I Know. This brings you a lot of wastage of dollars. not the best case for our scenario.
2.) Now, Let’s talk about the 2nd part. In this case, you don’t own the data center, you basically rent servers from a Cloud provider for say AWS for a short time or even a longtime or reserved it for a year. Here, you have servers(as Virtual Machines) running on the cloud, like EC2 (in AWS). if you need more servers, just configure the AutoScaling group.
If we consider the Scenario, It’s far better than the first part. Here your servers can scale up and down based on CPU utilization you set, but it has its own downfall,
Imagine you set an autoscale group with CPU utilization metric let’s say 70%, i.e. when more and more traffic hits and a moment your server CPU utilization reaches 70%, it spins up a new server. So far good,
From the above diagram, you could see that the new EC2 instance’s CPU utilization is 30%, but you have to pay for 100%. This means that whether your server utilizes 30% or 10% 0r 60% you have to pay as a whole. so, therefore this also isn’t a better solution for our scenario.
3.) Now Let’s talk on Paas (Platform as a Service), if we consider the scenario in this case, it’s lots more better than above two because here you don’t have to manage servers. servers management done by Cloud Provider, but somewhat you need to manage like scaling, here the main concern all about how you write code for your application. you write code and upload on like say Elastic Beanstalk (EBS) for AWS. In PaaS autoscaling is not intrinsic, developers need to scaleup and scale down based on user demand. Also, servers take a while to spin up. so, as in our scenario, we’re looking for a solution that is fully managed with very little configuration (<1) of servers, this also not the best solution.
4.) Moving towards, we finally came to the Serverless, Hurray! 😃. Since scaling and cost both, is our main concern as per our scenario. Before moving further and so, far you know what is serverless computing! Now, let’s talk about what makes a service serverless?
For a Service to be called as Serverless service:
a.) No need to manage or provision servers.
b.) Automatically Scaleup and down based on usage
c.) Never pay for idle.
d.) Built-in Fault tolerance and availability
There are a lot more, but here I discussed some major. so far we know what is serverless and what makes a service serverless, talking to our Scenario, this might be a best-case we’re looking for, you just need to write code and just deploy on a serverless service for case Lambda(AWS). Now, if we compare Elastic Beanstalk(as PaaS) and Lambda(as Serverless), lambda is far better because of its built-in scaling, Instant response not might in the case of EBS. but everything in the world is not perfect. Serverless in the case of Lambda it’s only run your code for a max of 15min. if your code takes a lot more time than this, you may look for container services. But if you overlooked this and thinking max 15min is very enough to run your code, this might be the best option, other serverless services Like APIGateway, DynamoDB, StepFunctions, SNS, SQS, and s3 all from AWS, and Lambda can easily establish with all these, for more details can look: https://www.cloudflare.com/learning/serverless/glossary/serverless-vs-paas/
So, Lastly, I want to say every Service has its own side-effects not all are perfect 😅. but for our scenario serverless is the best solution to opt. Remember one thing,
we don’t believe in one tool to rule the world. we want you to use the right tool for the right job. — Andy Jassy, CEO of AWS.