Hi, let’s discuss elasticity and also horizontal and vertical scaling and how we can use them to elevate our performance efficiency.
So what is scaling? Well, it is the ability of a system to scale, so increasing or decreasing the load placed upon that system. Systems scale when they need to grow or shrink depending on the load. So when it scales we are adding or removing resources to and from a system. And we have two ways to scale: vertical and horizontal.
An example of vertical scaling is, let’s say you have a particular size of an EC2 instance and that instance size is not able to keep up with the increase in demand. So the instance may start running very slowly, or in a worst case scenario it may cause the system to crash. So vertical scaling is resizing your EC2 instance to a larger size. Let’s say we were using a t2.micro, well maybe we may need to resize to a t2.medium or larger; and by resizing our instance we are actually adding more CPU and memory for our system to handle the increase in demand. And if you choose to scale vertically you will encounter a few issues, for example, there is usually a small disruption bc the instance when resized will need to rebooted.
And to tie in cost optimization, when you vertically scale to a larger or even larger instance size, you will also see an increase in your cost. And this is one area we can go back to our AWS Well-Architected Framework Cost Optimization Pillar to make sure we are right sizing our instances in the beginning. But some benefits of vertical scaling is that there is usually no application modifications needed and it usually works for all applications.
Now lets talk about horizontal scaling because it was designed to fix some of the issues we have with veritcal scaling. So with horizontal scaling, instead of increasing the size of our instance, we add more instances of the same size to handle that load. And instead of having one running copy of your application, you now have one for each instance that scaled. And we can use a load balancer to help distribute the load across all of our instances.
But we also have to consider certain things with horizontal scaling, one is sessions, so you do not want to interupt customers sessions with your applciations. When we have a single application running on a single server, then all of our sessions are stored on that server, but what do you think happens to our sessions when we scale to multi servers with copies of our application? Well, sometimes you are shifted between the instances because horizontal scaling is meant to even out the load, so the load balancer sends requests to different servers that have a copy of your application. So AWS recommends to enable sticky sessions so you do not lose your sessions switching between servers. And this works when scaling in or scaling out. Also, as far as cost optimization, this is usually less expensive bc you are using smaller cheaper instance sizes.
Now let’s cover Elasticity. What is elasticity? It is an important topic to know and understand for the exam. Elasticity is using automation along with horizontal scaling to match capacity/supply with the demand. You will notice that demand is very rarely linear, it is usually increasing and decreasing, and using elasticity it allows our capacity to increase and decrease and meet that ever changing demand. And AWS provides launch configurations and auto scaling to scale out our systems to match that capacity to that demand, allowing our environment to scale out adding additional resources as the demand increases and then when that demand decreases we can scale back in to smaller number of servers or even no servers which optimizes our env for performance efficiency, operational excellence as well as cost optimization as well which are all pillars of the AWS Well-Architected Framework.
So for the exam and in the real world, try to remember that vertical scaling is a larger instance size and horizontal scaling is more instances. And Elasticity is using automation along with horizontal scaling to match our capacity to our demand