What is auto scaling?

In short
Auto scaling is a way to change the number of servers running your application automatically, based on demand. When traffic rises, it adds servers. When traffic falls, it removes them. This keeps your app available and can reduce what you pay for idle capacity.
Auto scaling means your application adjusts how many servers it runs without someone changing settings by hand. In AWS, these servers are called EC2 instances, which are virtual machines you rent by the hour. Auto scaling watches the load and adds or removes instances to match it.
How it works
Instances are grouped into an Auto Scaling group. You set three numbers for each group. The minimum is the smallest number of instances the group will keep running. The maximum is the largest number it will ever run. The desired capacity is the count the group aims to hold at any moment.
If you add scaling policies, the group can launch or terminate instances as demand changes. A policy might add instances when the load on your app goes up and remove them when it goes down. The policy always stays inside your minimum and maximum limits. Each new instance is created from a launch template or launch configuration, which is a saved set of settings such as the machine image and instance type.
Health and resilience
Auto scaling checks the health of each instance using built-in EC2 health checks. If an instance stops working, the group terminates it and starts a replacement, so the group keeps the desired number of healthy instances. You can also define custom health checks that test something specific to your app, such as whether a page responds as expected.
You can spread a group across several Availability Zones, which are separate data center locations within one AWS region. Auto scaling tries to balance instances evenly across them. If one location fails, the rest keep serving traffic. Pairing the group with Elastic Load Balancing sends traffic only to healthy instances, and the load balancer is updated automatically when instances start or stop.
Cost and purchase options
A single group can mix instance types and purchase options, such as On-Demand and Spot Instances. Spot Instances are usually cheaper but can be interrupted. If that happens, auto scaling can request replacement Spot capacity. Capacity Rebalancing can also replace Spot Instances that look likely to be interrupted soon. Reserved Instances and Savings Plans can be used together with On-Demand instances in the same group.
There is no extra fee for Auto Scaling itself. You pay for the resources it uses, such as EC2 instances, EBS volumes, and CloudWatch alarms.
Updating and testing instances
When you change your machine image or launch template, instance refresh can replace instances gradually. This is called a rolling update. You can also run a canary deployment, which tests the new version on a small set of instances before the rest of the group receives it.
Lifecycle hooks let you run custom steps when an instance starts or before it is terminated. For example, you can save state or drain work from an instance first. Scale-in protection and custom termination policies can stop instances that are busy with long tasks from shutting down too early.
Common mistakes
A frequent mistake is setting the minimum and desired values too low, which leaves little room to absorb a sudden spike. Another is forgetting that the app must start quickly on a new instance, or the group keeps replacing instances that are not ready. Custom health checks help here, because they report whether the app itself works, not only whether the machine is running.
If you plan to use auto scaling, start with the tutorial in the official guide. Create one group, stop an instance, and watch it being replaced. That shows the behavior more clearly than any description.
Ways to manage groups
You can manage Auto Scaling groups in the AWS Management Console, with the AWS CLI, with AWS Tools for PowerShell, through the AWS SDKs for your language, or with CloudFormation templates. The SDKs handle many connection details, such as request signing and retries. The raw Query API gives the most direct access but leaves those details to your code.
FAQ
Does auto scaling cost extra?
Amazon EC2 Auto Scaling itself has no additional fees. You pay only for the AWS resources it uses, such as EC2 instances, EBS volumes, and CloudWatch alarms.
What is the difference between minimum and desired capacity?
The minimum is the lowest number of instances the group will ever run. Desired capacity is the number the group aims to maintain at a given time, and it must stay within the minimum and maximum.
Can auto scaling use cheaper Spot Instances?
Yes. A group can mix On-Demand and Spot Instances. If Spot Instances are interrupted, auto scaling can request replacement Spot capacity.
How does auto scaling work with a load balancer?
When instances launch or terminate, auto scaling registers or deregisters them with the load balancer. Traffic is then distributed only to healthy instances.
Sources
This page is based on the official documentation below. Read it for full detail.
Auto scaling — official documentation ↗