0
0
AWScloud~5 mins

Minimum, maximum, and desired capacity in AWS - Commands & Configuration

Choose your learning style9 modes available
Introduction
When running applications on the cloud, you want the right number of servers to handle your users. Minimum, maximum, and desired capacity help control how many servers run at once to save money and keep your app working well.
When you want to make sure your app always has at least a few servers running to handle traffic.
When you want to limit the maximum number of servers to avoid extra costs.
When you want to set a target number of servers to run under normal conditions.
When your app needs to automatically add or remove servers based on demand.
When you want to keep your app stable during traffic spikes or drops.
Config File - asg-config.json
asg-config.json
{
  "AutoScalingGroupName": "example-asg",
  "MinSize": 2,
  "MaxSize": 5,
  "DesiredCapacity": 3,
  "LaunchConfigurationName": "example-launch-config",
  "AvailabilityZones": ["us-east-1a", "us-east-1b"]
}

This JSON file configures an AWS Auto Scaling Group (ASG).

MinSize sets the minimum number of servers always running.

MaxSize limits the maximum number of servers to control costs.

DesiredCapacity is the target number of servers the ASG tries to maintain.

LaunchConfigurationName tells which server setup to use.

AvailabilityZones are the data center locations where servers run.

Commands
This command creates an Auto Scaling Group named 'example-asg' with minimum 2 servers, maximum 5 servers, and desired 3 servers running in two availability zones.
Terminal
aws autoscaling create-auto-scaling-group --auto-scaling-group-name example-asg --launch-configuration-name example-launch-config --min-size 2 --max-size 5 --desired-capacity 3 --availability-zones us-east-1a us-east-1b
Expected OutputExpected
No output (command runs silently)
--min-size - Sets the minimum number of servers to keep running
--max-size - Sets the maximum number of servers allowed
--desired-capacity - Sets the target number of servers to run
This command checks the current settings and status of the 'example-asg' Auto Scaling Group to confirm the capacities.
Terminal
aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names example-asg
Expected OutputExpected
{ "AutoScalingGroups": [ { "AutoScalingGroupName": "example-asg", "MinSize": 2, "MaxSize": 5, "DesiredCapacity": 3, "Instances": [], "AvailabilityZones": ["us-east-1a", "us-east-1b"] } ] }
--auto-scaling-group-names - Specifies which Auto Scaling Group to describe
This command changes the desired capacity to 4, telling AWS to add one more server to the group.
Terminal
aws autoscaling update-auto-scaling-group --auto-scaling-group-name example-asg --desired-capacity 4
Expected OutputExpected
No output (command runs silently)
--desired-capacity - Updates the target number of servers
Check again to see that the desired capacity has changed to 4 and the group is adjusting.
Terminal
aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names example-asg
Expected OutputExpected
{ "AutoScalingGroups": [ { "AutoScalingGroupName": "example-asg", "MinSize": 2, "MaxSize": 5, "DesiredCapacity": 4, "Instances": [], "AvailabilityZones": ["us-east-1a", "us-east-1b"] } ] }
--auto-scaling-group-names - Specifies which Auto Scaling Group to describe
Key Concept

If you remember nothing else from this pattern, remember: minimum capacity keeps your app safe, maximum capacity controls cost, and desired capacity balances how many servers run right now.

Common Mistakes
Setting desired capacity lower than minimum size
AWS will ignore desired capacity below minimum and keep minimum servers running, causing confusion.
Always set desired capacity equal or higher than minimum size.
Setting maximum size lower than minimum size
This is invalid and AWS will reject the configuration.
Ensure maximum size is always equal or greater than minimum size.
Not updating desired capacity after changing min or max sizes
The group may not scale as expected if desired capacity is out of new bounds.
Update desired capacity to fit within new min and max sizes.
Summary
Create an Auto Scaling Group with minimum, maximum, and desired capacity to control server count.
Use describe commands to check current capacity settings and group status.
Update desired capacity to scale the number of servers up or down as needed.