Auto-Scaling Groups

Autoscaling - Setting Up and Using Scaling Groups

Autoscaling enables the correct number of EC2 instances to be available in order to handle application loads. To implement autoscaling, create collections of EC2 instances, called scaling groups. A simple autoscaling group with a specific desired capacity can be created. The autoscaling group will maintain the specified number of instances by making sure that when an instance fails, it starts a new instance to replace the failed instance.

Add policies to an autoscaling group in order to instruct the group to maintain a performance metric as close as possible to a threshold. For example, CPU load can be kept close to 50% (but not above it). To achieve this goal, the autoscaling group creates and terminates instances as needed, when the load on the instances fluctuates.

An autoscaling group detects unhealthy instances. When the group detects an unhealthy instance, it terminates and deletes it, and then replaces it with a new instance.

Target groups can also be connected to autoscaling groups, so that all instances in the autoscaling groups are also added to all connected target groups.

Implementing auto-scaling groups

  1. Create a launch configuration - A launch configuration is a template that specifies the type of VM instance that autoscaling creates. Launch configurations specify things such as the image to use for launching an instance, the instance type, key pairs, and security groups.

  2. Create an auto-scaling group - when creating an auto-scaling group:

    • Specify the launch configuration to use for the VMs in the group.

    • Also specify the number of instances that are available to the group, the metrics to monitor when determining appropriate group size, the type of health checks to use, and various other settings.

Creating Launch Configurations

When an auto-scaling group automatically adds a new VM, the new VM inherits the characteristics defined in the scaling group’s launch configuration.

  1. In Menu > Compute, select Launch Config, and then click Create. The Create Launch Configuration window is displayed.

    create-launch-configuration

In the Create Launch Configuration window fill in the following fields:

  • Name - The name of the launch configuration being created.

  • Image - Select the image to ase the scaling group’s instance on.

  • Instance Type - An instance type specifies the CPUs, RAM, and boot disk size to use for the instance. Select an instance type from the drop down menu.

  • Security Groups - (Optional) Select the security group(s) for the scaling group’s VMs to use.

  • Key Pair - (Optional) Select the key pair for the scaling group’s VMs to use.

  • Read cloud-init from file - (Optional) For the scaling group’s VMs to use a cloud-init file during the boot process, specify the cloud init file here.

  1. Click Next. The Image tab is displayed.

  2. Select an Image from the drop-down.

  3. (Optional) slide to Override Block Device Mapping. The Image tab is displayed with the Override Block Device Mapping properties.

slide-override-blockdevice-mapping

The Override Block Device Mapping properties widnow includes the following details:

  • Block Device Mapping - Add Multiple Block Device Mapping options, that include the following properties:

    • Snapshot-Volume – Select the Snapshot/Volume from the dropdown.

    • Storage Pool - Select the specific storage pool to upload this image to.

    • Use Legacy IDE - Determine whether to use the legacy IDE or the native IDE (Default).

    • Override Size - Select in order to keep the image the same size (Default) or to override it. To override the size, enter the new size.

    • Disk Type - Select if the image will be attached as a Disk (Default) or CDROM.

  1. Click the OK button. The image begins to be created. Its progress is displayed in Image list. When the uploading progress is completed, the Action Succeeded message is displayed in the Launch Configuration list.

Creating Auto-Scaling Groups

An auto-scaling group is a collection of EC2 instances that your application can use to handle its workload. When creating an auto-scaling group, specify how many instances are available to the group, and which metrics to monitor to determine the appropriate group size for any given application load. After the scaling group creates the instances, it monitors both instance metrics and instance health to make sure the optimal number of functional instances exist.

  1. In Menu > Compute, select Auto-Scaling Groups, and then click Create. The Create Auto-Scaling Groups window is displayed.

    auto-scaling-1

In the Scaling Policy window fill in the following fields:

  • Group Setup - Give the group a name, capacity and launch configuration:

    • Name - The group name of the auto-scaling group.

    • Description - Optional. The description of the auto-scaling group.

    • Size Limit - Minimum and mazimum numbers of instances that the group can contain.

    • Desired Capacity - Optional. The Desired Capacity field also affects the number of instances in the group. The role of the Desired Capacity field depends on whether or not a scaling policy is set:

      • When scaling policy is set: Specify the number to be defined. This is the capaciy which determines the number of instances in the group. In this case, desired capacity must be within the limits of min./max. capacity (set in the Size Limit field). If no capacity is specified when the group is created, the system sets Desired Capacity to the minimum size in the Size Limit field.

      • When no scaling policy is set: The Desired Capacity determines the initial number of instances, after which the scaling policies take charge and might change the desired capacity (within the limits set by min./max. capacity).

    Tip

    Set the Desired Capacity to zero.

    There are several situations when the desired system Capacity can equal zero:

    • When, temporarily, no group is needed: Set the Desired Capacity to zero. In this event, the group still exists. without consuming resources. Therefore, there is no need to create the group or the scaling policies from sccratch at a later stage.

    Note

    Forcibly deleting a group with instances

    The system automatically sets Desired Capacity to zero, and starts removing instances. When there are no instances, the system deletes the group.

    • Subnet - Select the subnet from the drop-down.

    • Launch Configuration - The configuration that should be used for the EC2 instances in the group. Launch configurations are templates that specify the characteristics of each instance.

    • Tags - Tag the group with attributes that assist the grouping criteria.

  1. Click Next. The Scaling Policy tab is displayed.

create-asg-scaling-policy

In the Scaling Policy tab, set the scaling policies for the following metrics by sliding them:

  • CPU Utilization

  • Network Traffic - In

  • Network Traffice - Out

  1. Click Next. The Advance tab is displayed.

create-asg-advanced

In the Advanced tab, fill in the following details:

  • Health Check - (Optional) Select the type of health check to use on instances:

    • VM Health - Use VMware’s VM Monitor tool.

    • Target Group - Use ELB health checks. This choice is available only if the scaling group is associated with a load balancer target group.

  • Target Groups - (Optional) To associate the scaling group with one or more load balancer target groups select the target group(s) here.

  • Operation Cooldown - (Optional) How many seconds to wait between the end of one scaling operation and the start of another. The operatiion cooldown period helps to ensure that autoscaling doesn’t launch or terminate additional instances before the previous scaling activity takes effect. After the scale group dynamically scales, it waits for the cooldown period to complet before resuming scaling activities.

  • Health Check Grace Period - Minimal length of time before checking the health status of an instance.

  • Termination Policies - (Optional) When the scaling group performs a scale-in operation (removes instances from the group), specify that it should follow one of these policies:

    • Default. Terminate instances that have the oldest launch configuration.

    • Oldest Instance. Terminate the oldest instance in the useful when upgrading the instances in the Auto Scaling group to a new EC2 instance type. Gradually replace instances of the old type with instances of the new type.

    • Newest Instance. Terminate the newest instance in the group. This policy is useful when testing new launch configurations but don’t want to keep it in production.

    • Oldest Launch Configuration. Terminate instances that have the oldest launch configuration. This policy is useful when updating a group and phasing out the instances from a previous configuration.

  • Protect Instances from Scale-In - (Optional) Protects instances that get added to the group from ever being automatically removed. During the time period when this protection option is set for the group, any instances that get added to the scaling group are exempt from the group’s termination policies – they will never be removed from the group. The effect of the use case where the desired capacity is reduced, is as follows:

    • When the desired capacity is reduced (either automatically or manually), other instances will be terminated (those that were created while protected from scale-in were not in effect).

    • When all instances are protected from scale-in, the group will not be able to reach its desired capacity because it cannot get rid of any instance.

  1. Click Finish. After a number of seconds, the Action Succeeded message is displayed. The Auto-Scaling Group is displayed in the Compute > Auto-Scaling Group list.

Load Balancing and Scaling Groups

Associate a scaling group with a load balancer’s target group. The scaling group then guarantees the load balancer that the load balancer will have a given number of healthy instances among which it can distribute an application’s workload.

Consider the following scenario involving these four sample entities:

  • MyApplication

  • LoadBalancerA

  • TargetGroupA

  • ScalingGroupA

Scenario:

  • MyApplication directs its requests to LoadBalancerA.

  • LoadBalancerA is associated with TargetGroupA. TargetGroupA has just one instance.

  • ScalingGroupA is managing 20 instances (doing health checks and making sure that there are always 20 healthy instances available). ScalingGroup A is also associated with TargetGroupA.

Because of this association, LoadBalancerA can distribute MyApplication’s work among 21 instances – one in TargetGroupA and 20 in ScalingGroupA.


Support AWS-EC2 Autoscaling APIs

The table below describes the AWS-EC2 Autoscaling APIs that Zadara Cloud Services support. Together with their supported Required and Optional request parameters and Ignored and Unsupported parameters. (Ignored parameters refer to parameters used by Terraform which are not support, but their usage does not cause an error message to be sent. Unsupported parameters send an “unsupported” error.)

For complete AWS documentation for each action, see AWS documentation.

Name

Required Parameters

Optional Parameters

Ignored Parameters

Unsupported Parameters

AttachInstances

  • AutoScalingGroupName

  • InstanceIds

AttachLoadBalancerTargetGroups

  • AutoScalingGroupName

  • TargetGroupARNs

CreateAutoScalingGroup

  • AutoScalingGroupName

  • LaunchConfigurationName

  • MaxSize

  • MinSize

  • AvailabilityZones

  • DefaultCooldown

  • DesiredCapacity

  • HealthCheckGracePeriod

  • HealthCheckType

  • NewInstancesProtectedFromScaleIn

  • ServiceLinkedRoleARN

  • Tags

  • TargetGroupARNs

  • TerminationPolicies

  • VPCZoneIdentifier

  • InstanceId

  • LaunchTemplate

  • LifecycleHookSpecificationList

  • LoadBalancerNames

  • PlacementGroup

CreateLaunchConfiguration

  • LaunchConfigurationName

  • ImageId

  • KeyName

  • InstanceType

  • SecurityGroups

  • UserData

  • BlockDeviceMappings

  • RamdiskId

  • InstanceMonitoring

  • EbsOptimized

  • AssociatePublicIpAddress

  • PlacementTenancy

  • BlockDeviceMappings

  • RamdiskId

  • InstanceMonitoring

  • EbsOptimized

  • AssociatePublicIpAddress

  • PlacementTenancy

  • InstanceId

  • ClassicLinkVPCId

  • ClassicLinkVPCSecurityGroups

  • IamInstanceProfile

  • KernelId

  • SpotPrice

CreateOrUpdateTags

  • Tags

DeleteAutoScalingGroup

  • AutoScalingGroupName

  • ForceDelete

DeleteLaunchConfiguration

  • LaunchConfigurationName

DeletePolicy

  • PolicyName

  • AutoScalingGroupName

DeleteScheduledAction

  • AutoScalingGroupName

  • ScheduledActionName

DeleteTags

  • Tags

DescribeAutoScalingGroups

  • AutoScalingGroupNames

  • MaxRecords

  • NextToken

DescribeLaunchConfigurations

  • LaunchConfigurationNames

DescribePolicies

  • AutoScalingGroupName

  • PolicyNames

  • PolicyTypes

DescribeScalingActivities

  • ActivityIds

  • AutoScalingGroupName

  • MaxRecords

  • NextToken

DescribeScheduledActions

  • AutoScalingGroupName

  • EndTime

  • ScheduledActionNames

  • StartTime

  • MaxRecords

  • NextToken

DescribeTags

  • Filters

DetachInstances

  • AutoScalingGroupName

  • InstanceIds

  • ShouldDecrementDesiredCapacity

DetachLoadBalancerTargetGroups

  • AutoScalingGroupName

  • TargetGroupARNs

EnterStandby

  • AutoScalingGroupName

  • InstanceIds

  • ShouldDecrementDesiredCapacity

ExitStandby

  • AutoScalingGroupName

  • InstanceIds

PutScalingPolicy

  • PolicyName

  • AutoScalingGroupName

  • PolicyType

  • EstimatedInstanceWarmup

  • TargetTrackingConfiguration

  • AdjustmentType

  • Cooldown

  • MetricAggregationType

  • MinAdjustmentMagnitude

  • MinAdjustmentStep

  • ScalingAdjustment

  • StepAdjustments

PutScheduledUpdateGroupAction

  • AutoScalingGroupName

  • ScheduledActionName

  • DesiredCapacity

  • EndTime

  • MaxSize

  • MinSize

  • Recurrence

  • StartTime

  • Time

UpdateAutoScalingGroup

  • AutoScalingGroupName

  • AvailabilityZones

  • DefaultCooldown

  • DesiredCapacity

  • HealthCheckGracePeriod

  • HealthCheckType

  • LaunchConfigurationName

  • MaxSize

  • MinSize

  • NewInstancesProtectedFromScaleIn

  • ServiceLinkedRoleARN

  • TerminationPolicies

  • VPCZoneIdentifier

  • LaunchTemplate

  • PlacementGroup