Auto Scaling allows you to scale your Amazon EC2 capacity up or down automatically according to conditions you define. With Auto Scaling, you can ensure that the number of Amazon EC2 instances you are using increases seamlessly during demand spikes to maintain performance, and decreases automatically during demand lulls to minimize costs. Auto scaling is particularly well suited for applications that experience hourly, daily, or weekly variability in usage.
With Auto Scaling, you can plan to configure your Auto Scaling Group to automatically scale or maintain your application. You can configure three types of plans:
Maintain a Fixed Number of Running EC2 Instances
Use this scaling plan if you would like Auto Scaling to maintain the minimum number of instances in your Auto Scaling group at all times. You can manually change the number of running instances in your Auto Scaling group at any time.
Scale Based on Demand
Use this scaling plan if you need to scale dynamically in response to changes in the demand for your application. When you scale based on demand, you must specify when and how to scale using CloudWatch metrics like CPU or Network usage or metrics related to Simple Queue Service
Scale Based on a Schedule
Use this scaling plan if you want to scale your application on a pre-defined schedule. You can specify the schedule for scaling one time only or provide details for scaling on a recurring schedule.
Using Elastic Cloud Gate Auto Scaling Wizard, you will be able to configure any of these options.
This section will walk you through each tab of our wizard, explaining what option does what and what dependencies are between options.
Launch Configuration
Configuration Name [required]: The name of the launch configuration
Image ID [required]: Unique ID of the Amazon Machine Image (AMI) you want to use to launch your EC2 instances inside Auto Scaling
Instance Type [required]: The type of the instance launch inside Auto Scaling
Instance Name [optional]: When specified, each new instance launch in Auto Scaling will have automatically assigned tag name.
Scaling Group
Group Name [required]: The name of the scaling group
VPC Subnetwork [required/optional]: list of the VPC subnetwork in which you prefer auto scaling will launch instances. Either subnetwork(s) or availability zone(s) need to be specified.
Availability Zones [required/optional]: list of availability zones in which you prefer auto scaling will launch instances
Security Group [optional]: Security group that will be associated with instances in Auto Scaling group
Health Check Type [required]: the type of the service that will be used to check the health of the instances. The allowed values could be either EC2 or ELB. When ELB is selected, you will have to specify the name of the Elastic Load Balancer, which will check the health of instances. Default value is EC2.
Elastic Load Balancer [optional]: The name of the Elastic Load Balancer. This property is required when Health Check Type is set to ELB
Minimum Size [required]: The minimum count of instances that should run inside the Auto Scaling group. This value can be overwritten by Desire Capacity (see below).
Maximum Size [required]: The maximum count of instances that might be created inside of the Auto Scaling group. This property will be mostly applicable when you use schedule based on demand.
Desired Capacity [optional]: The number of Amazon EC2 instances that should be running in the group. The desired capacity must be greater than or equal to the minimum size and less than or equal to the maximum size specified for the Auto Scaling group. When specified, that will be the total number of instances launched right after creating Auto Scaling group.
Health Check/Grace Period [optional]: Length of time in seconds after a new Amazon EC2 instance comes into service, when Auto Scaling starts checking its health. During this time any health check failure for that instance will be ignored. Default value 300 seconds.
Cooldown [optional]: The amount of time, in seconds, between a successful scaling activity and the succeeding scaling activity. Default value 300 seconds.
Scaling Policy
When you use Auto Scaling to scale on demand, you must define how you want to scale in response to changing conditions. Let's say, for example, that you have a web application that currently runs on two instances. You want to launch two additional instances when the load on the running instances reaches 70 percent, and then you want to terminate the additional instances when the load goes down to 40 percent. You can configure your Auto Scaling group to automatically scale up and then scale down based on specifying these conditions.
An Auto Scaling group uses a combination of policies and alarms to determine when the specified conditions for launching and terminating instances are met. An alarm is an object that watches over a single metric (for example, the average CPU utilization of your EC2 instances in an Auto Scaling group or length of the queue in SQS) over a time period that you specify. When the value of the metric breaches the thresholds that you define, over a number of time periods that you specify, the alarm performs one or more actions. An action can be sending messages to Auto Scaling. A policy is a set of instructions for Auto Scaling that tells the service how to respond to alarm messages.
Along with creating a launch configuration and Auto Scaling group, you need to create the alarms and the scaling policies and associate them with your Auto Scaling group. When the alarm sends the message, Auto Scaling executes the associated policy on your Auto Scaling group to scale the group in (that is, to terminate instances) or scale the group out (that is, to launch instances).
Adjustment Type [required]: Indicates whether the ScalingAdjustment is an absolute value, a constant increment, or a percentage of the current capacity.
ChangeInCapacity:
Use this to increase or decrease existing capacity. For example, let's say that the current capacity of your Auto Scaling group is set to three instances. You then create a scaling policy on your Auto Scaling group, specify the type as ChangeInCapacity and the adjustment as five. When the policy is executed, Auto Scaling will add five more instances to your Auto Scaling group. You'll then have eight running instances in your Auto Scaling group: current capacity (3) plus ChangeInCapacity (5) equals (8).
ExactCapacity:
Use this to change the current capacity of your Auto Scaling group to the exact value specified. For example, let's say that the capacity of your Auto Scaling group is set to five instances. You then create a scaling policy on your Auto Scaling group, specify the type as ExactCapacity and the adjustment as three. When the policy is executed, your Auto Scaling group will have three running instances. You'll get an error if you specify a negative adjustment value for the ExactCapacity adjustment type.
PercentChangeInCapacity:
Use this to increase or decrease the desired capacity by a percentage of the desired capacity. For example, let's say that the desired capacity of your Auto Scaling group is set to ten instances. You then create a scaling policy on your Auto Scaling group, specify the type as PercentChangeInCapacity and the adjustment as ten. When the policy is executed, your Auto Scaling group will have eleven running instances because 10 percent of 10 instances is 1 instance, and 1 instance plus 10 instances equals 11 instances.
Scaling Adjustment [required]: The number of instances by which to scale. AdjustmentType determines the interpretation of this number (e.g., as an absolute number or as a percentage of the existing Auto Scaling group size). A positive increment adds to the current capacity and a negative value removes from the current capacity.
Cooldown [optional]: The amount of time, in seconds, after a scaling activity completes and before the next scaling activity can start. Default value 300 seconds.
Minimum Adjustment Step [optional]: Used with AdjustmentType with the value PercentChangeInCapacity, the scaling policy changes the DesiredCapacity of the Auto Scaling group by at least the number of instances specified in the value.
Metrics
Metric Namespace [required]:
- Select EC2 when you want to scale based on the EC2 metrics like CPU or Network usage
- Select SQS when you want to scale based on the Simple Queue Service metrics like number of sent Messages or size of sent message.
Metric [required]: Metric that will be used for auto scaling
Dimension [optional/required]: This option will be active only when the SQS namespace was selected. It lets you select a queue name to which the metric will be applicable.
Alarm Name [required]: The name of the alarm.
Statistic [required]: The statistic to apply to the alarm's associated metric.
Period [required]: The period in seconds over which the specified statistic is applied. The value has to be a multiply of 60. The total (Period * Evaluation Period) cannot be greater than 86400. In our wizard we use minutes instead of seconds so the maximum combined value cannot be greater than 1440.
Threshold [required]: The value against which the specified statistic is compared.
Evaluation Period [required]: The number of periods over which data is compared to the specified threshold. The total (Period * Evaluation Period) cannot be greater than 86400.
Comparison Operator [required]: The arithmetic operation to use when comparing the specified Statistic and Threshold. The specified Statistic value is used as the first operand.
Scaling Schedule
Scaling based on a schedule allows you to scale your application in response to predictable load changes. Let’s say that every week the traffic to your web application starts to increase on Wednesday, remains high on Thursday, and starts to decrease on Friday. You can plan your scaling activities based on the predictable traffic patterns of your web application.
To configure your Auto Scaling group to scale based on a schedule, you need to create scheduled actions. A scheduled action tells Auto Scaling to perform a scaling action at certain time in future. To create a scheduled scaling action, you specify the start time at which you want the scaling action to take effect, and you specify the new minimum, maximum, and desired size you want for that group at that time. At the specified time, Auto Scaling updates the group to set the new values for minimum, maximum, and desired sizes, as specified by your scaling action. In addition, instead of using start time, you can use recurrent schedule that will change Auto Scaling options on the regular bases. E.g. assuming that the traffic to your website will decrease on weekend days, you can schedule two recurrent occurrences where first will increase capacity on each Monday and second decrease capacity on each Friday.
Start Time [required/optional]: The time when the scaling action should occur.
End Time [required/optional]: The time when the scaling action should end. This value applies only when Recurrence is set as well. Otherwise it will be skipped.
Recurrence [required/optional]: The time when recurring future actions will start. When Start Time and End Time are specified with Recurrence, they form the boundaries of when the recurring action will start and stop.
Minimum Size [required]: The minimum count of instances that should run inside the Auto Scaling group. This value can be overwritten** by Desire Capacity (see below).
Maximum Size [required]:The maximum count of instances that might be created inside of the Auto Scaling group.
Desired Capacity [optional]: The number of Amazon EC2 instances that should be running in the group. The desired capacity must be greater than or equal to the minimum size and less than or equal to the maximum size specified for the Auto Scaling group. When specified, that will be the total number of instances launched right after creating Auto Scaling group.
Notification
Topic Name [required]: Name of the topic
Notification Type [required]: A list of Auto Scaling notification types, which are events that will cause the notification to be sent. The following table lists the available notification types:
Notification Type Events:
EC2_INSTANCE_LAUNCH
Successful instance launch by Auto Scaling.
EC2_INSTANCE_LAUNCH_ERROR
Failed instance launch by Auto Scaling.
EC2_INSTANCE_TERMINATE
Successful instance termination by Auto Scaling.
EC2_INSTANCE_TERMINATE_ERROR
Failed instance termination by Auto Scaling.
Delivery Type [required]:
- EMAIL – notification will be delivered via email
- SMS – notification will be delivered via SMS. (SMS delivery is available only in the US East Region).
Subscriber [required]: either email address or phone number (for SMS delivery) where the message will be sent. The SMS can be only delivered to US phone numbers.
Finish
On the last tab of our wizard, you will get the summary of your configuration of Auto Scaling.
From this point on, you can either create auto scaling or generate CloudFormation script.
Keep in mind that CloudFormation has couple of limitations, which are:
- CloudFormation is not supporting schedule
- In scaling policy, CloudFormatiion is not supporting Minimum Adjustment Step
Watch our Wizard in Action