liveBook · Manning

Auto-scaling group

As explained in Amazon Web Services in Action, Third Edition: An in-depth guide to AWS

An Auto Scaling group is an AWS-managed collection of compute instances that maintains configured capacity and replaces or adjusts instances according to policies.

An Auto Scaling group manages a pool of EC2 instances. It launches instances from a launch template, keeps the configured number running, and replaces instances that fail health checks. It can also grow or shrink the pool as demand changes. section 17.1 section 13.2.2

Configure the group around a launch template:

  • Put the AMI, instance type, security settings, and bootstrap script in the launch template. Put the subnets where instances may run in the Auto Scaling group. section 13.2.2
  • Set minimum, maximum, and desired capacity. The minimum protects baseline capacity; the maximum limits how far the pool—and its cost—can grow. section 17.1
  • Choose EC2 or load-balancer health checks, allow a grace period for startup, and attach a load-balancer target group when instances serve web requests. section 17.1
  • Add a scaling policy when fixed capacity is not enough. A schedule handles predictable changes; a CloudWatch alarm can respond to a metric such as CPU usage. section 17.2
Table 17.2 Auto Scaling group parameters (view table figure)

Name

Description

Possible values

DesiredCapacity

Desired number of healthy virtual machines

Integer

MaxSize

Maximum number of virtual machines; the upper scaling limit

Integer

MinSize

Minimum number of virtual machines; the lower scaling limit

Integer

HealthCheckType

How the Auto Scaling group checks the health of virtual machines

EC2 (health of the instance) or ELB (health check of instance performed by a load balancer)

HealthCheckGracePeriod

Period for which the health check is paused after the launch of a new instance to wait until the instance is fully bootstrapped

Number of seconds

LaunchTemplate

ID (LaunchTemplateId) and version of launch template used as a blueprint when spinning up virtual machines

ID and version of launch template

TargetGroupARNs

The target groups of a load balancer, where autoscaling registers new instances automatically

List of target group ARNs

VPCZoneIdentifier

List of subnets in which to launch EC2 instances

List of subnet identifiers of a VPC

Use the parameter table to check the capacity, health-check, launch-template, and target-group settings before creating a group. section 17.1

Recover a Jenkins server across availability zones

Set MinSize and MaxSize to 1 and allow subnets in two availability zones. If the instance is terminated, the group starts a replacement; its instance ID and IP addresses can change. Store Jenkins state on EFS rather than relying on an EBS volume tied to one availability zone. Provide a stable endpoint separately, because replacing an instance does not preserve its IP addresses. section 13.2.2 section 13.2.3

Scale web servers and workers

A WordPress group uses a load balancer and a target-tracking policy based on average CPU usage. A separate queue-processing example uses CloudWatch alarms and step scaling to add a worker when an SQS queue grows. In both cases, keep shared data off replaceable instances and give clients a stable load-balancer or queue entry point. section 17.3.1 section 17.3.2 section 17.3

Groups also support deployments: update the launch template to use a newly built AMI, then use a rolling update to replace instances. Scaling and replacement improve resilience, but they do not by themselves preserve local state or give a replacement instance the same address. Remove example stacks when finished to avoid unwanted charges. section 15.3 section 13.2.3

How Amazon Web Services in Action, Third Edition: An in-depth guide to AWS covers it

How deep it goes
Works through launch-template and group settings, health checks, capacity bounds, and scaling policies using CloudFormation examples.
Examples
Uses Jenkins recovery, a load-balanced WordPress blog, and queue-driven screenshot workers as concrete configurations.
What it assumes
Introduces group and launch-template roles while building on EC2 instances, subnets, and CloudFormation deployment commands.
What you can do after
Operate/configure it with CloudFormation to replace failed instances or adjust a web or worker fleet with scaling policies.
How it connects
Connects launch templates and CloudWatch scaling policies with load balancers, SQS queues, stateless servers, and availability zones.

Also explained in

Compare how 2 books explain auto-scaling group →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Amazon Web Services in Action, Third Edition: An in-depth guide to AWS. The section links point to the parts of the book it draws on.