Blogger news

Blogger templates

Sunday, November 5, 2017

Cloud computing without auto scaling is almost same as traditional computing

I had no plan to write this article until I have seen below question in StackOverflow today, 

"My 2-CPU usage reached 100% very frequently and I need to restart my server again. For a while, it works fine but after few minutes it reaches 100%. Because of 100% usage of CPU, my website goes slow and not able to open it easily"

The main idea behind cloud computing is not to end up with a situation like this. If you have a well-architectured cloud platform then you wouldn't end up with a situation like this. If you are running out of resource in the cloud then there is no difference between traditional application hosting and cloud apart from cost. One thing is sure this happened because of the way it architectured the servers.

Elasticity is the real beauty of cloud computing. Elasticity means to expand and contract on its own when needed. We should architecture the cloud infrastructure in such a way that the load or resource utilization goes above certain limit spin up another server and remove the newly created instance when there is not enough load or low resource utilization. In traditional computing, this won't happen. If we need to cope up with the load then we have to manually provision the servers depends on high load, which means it is not elastic

In cloud computing elasticity is 'Auto Scaling'. As the name indicates scale out and scale in automatically when needed. Once we set up the infrastructure then we don't need to worry about the application load or resource utilization as everything will be automatically handled based on the continued monitoring and health check of the systems.

Let me explain with an example. Say I have only one web server hosted in the cloud and is not enabled. Think the server capacity is to handle on 10K request in a second. What happens if is getting 100K requests in a second? No doubt it will crash because of high utilization of system resources.

Now let me redesign the architecture like below design.

With the new design, we put our EC2 (AWS virtual machine) instance behind an elastic load balancer (ELB) and EC2 will continuously monitor for resource utilization like CPU, memory etc. I have architectured in such a way that whenever CPU utilization reaches 60% then create another EC2 instance immediately and attach it automatically to the ELB. Now we have a flexible design to distribute the load to another server which spins automatically and attach to ELB. Like this, you can spin up automatically more and more servers based on load and other requirements. Happy days!. Now we don't need to bother about the application load or resource utilization as autoscaling will scale out on its own.

What if we don't need the servers spin up automatically when there isn't enough load or under resource utilization? Then do the reverse process

The CPU utilization reaches 59%, which means we don't need another server to distribute the load as the primary server can handle it. Now we can delete the EC2 instance created and detach it from ELB, which will do automatically. Whenever load reaches 60% again it will create new instance again automatically and attach to ELB and so on.

If you don't have elasticity then you will not get real benefits of cloud computing.

No comments:

Post a Comment