Amazon EC2 - Auto Scaling

Natasha Ong
This is some text inside of a div block.
4 min read

In a nutshell:

You can scale your EC2 instances vertically by resizing the instance, or horizontally by launching new instances and adding them to the pool.
You can set up automated horizontal scaling using Amazon EC2 Auto Scaling.
Within Amazon EC2 Auto Scaling, you can use two approaches: dynamic scaling and predictive scaling.
Dynamic scaling responds to changing demand.
Predictive scaling automatically schedules the right number of Amazon EC2 instances based on predicted demand.
You can set limits for how many EC2 instances can run (and charge your account) by setting the minimum, desired and maximum capacity.

Scalability

If you’ve ever tried to visit a website that wouldn’t load or frequently shut down, the website might be getting more visitors than it could handle. This situation is similar to waiting in a long line at a coffee shop, when there is only one barista to take orders from customers and make all the coffee too. Scalability helps to avoid these situations.

Scalability means beginning with only the resources you need, and then responding to changing demand by adding or decreasing those resources. For example, more computing power would support a website when it's receiving lots of visitors, and the extra resources get removed the moment traffic starts to go back to normal again.

This is a great help for:

  • Keeping your application available when it's needed
  • Never for paying more than what you need.

Now there are two ways to handle growing demands. You can scale up, or scale out.

  1. Scaling up is also called vertical scaling, and it means adding more computing power to the EC2 instances that are currently running.
  2. Scaling out is also called horizontal scaling, and it means adding more EC2 instances.

If you wanted the scaling process to happen automatically, which AWS service would you use? The AWS service that provides this functionality for Amazon EC2 instances is Amazon EC2 Auto Scaling.

Amazon EC2 Auto Scaling

Amazon EC2 Auto Scaling lets you automatically add or remove Amazon EC2 instances in response to changing demand.

Within Amazon EC2 Auto Scaling, you can use two approaches: dynamic scaling and predictive scaling. To scale faster, you can use dynamic scaling and predictive scaling together.

  • Dynamic scaling: EC2 Auto Scaling responds to changing demands in real time by adding or removing instances.
  • Predictive scaling: EC2 Auto Scaling can automatically schedule the right number of Amazon EC2 instances based on what it expects demand to look like.

Configuring Auto Scaling

Suppose that you are preparing to launch an application on Amazon EC2 instances. Because you pay for only the EC2 instances you use, you can set limits for how many EC2 instances can run (and charge your account) at once.

When you configure the Auto Scaling group for your instances, you set:

  1. The minimum capacity - the number of Amazon EC2 instances that launch immediately after you have created the Auto Scaling group. For example, if you set the minimum capacity at one, there must be at least one EC2 instance running at all times.
  2. The desired capacity -  the ideal number of EC2 instances running at any given time. You believe the desired capacity is necessary for your application to run smoothly without overloading or underutilising your resources. For example, you might set desired capacity at two EC2 instances, even though it only needs a minimum of a one instance to run. Note: If you do not specify the desired number of Amazon EC2 instances in an Auto Scaling group, the desired capacity defaults to your minimum capacity.
  3. The maximum capacity. For example, your Auto Scaling group can scale out only to a maximum of four EC2 instances.