Skip to content

Instantly share code, notes, and snippets.

@ross-humphrey
Created December 13, 2019 16:00
Show Gist options
  • Save ross-humphrey/c78c16a7e6be81af5cb67e4f8ea1d9a8 to your computer and use it in GitHub Desktop.
Save ross-humphrey/c78c16a7e6be81af5cb67e4f8ea1d9a8 to your computer and use it in GitHub Desktop.
🧪 Introduction to Amazon EC2 Auto Scaling
Introduction to Amazon EC2 Auto Scaling
---------------------------------------------------------------------------------------------------------------------------
Amazon EC2 Auto Scaling:
> Helps you ensure you have the correct number of EC2 instances available to handle applications workload.
> You create collections of Ec2 instances called 'Auto Scaling Groups'
> Specify the minimum number
> Specify the maximum number
> When this is done the number of EC2s will never drop or exceed said numbers.
> If you specify a desired capacity auto scaling ensures that your group always has fixed number of instances
> If you specify scaling policies then Auto scaling will launch new instances or terminate existing instances
when the demand increases or decreases.
> Auto scaling only launches new instances or terminates existing - it does not STOP and START.
---------------------------------------------------------------------------------------------------------------------------
Auto Scaling Group
> EC2 instances are organized into Auto scaling groups - treated as a logical unit for scaling and management.
> Specify minimum nad maxmimum desired number of EC2s.
---------------------------------------------------------------------------------------------------------------------------
Launch Configuration
> Auto scaling group uses a Launch configuration as a template for launching nerw Ec2 instances.
> When created you can specify information such as the AMI ID, instance type, key pair,
security groups, and block device mapping for you instances.
---------------------------------------------------------------------------------------------------------------------------
Scaling Plans:
(Tell EC2 how to scale)
> Maintain current instance levels at all time:
> Auto scaling performs periodic health check
> When an unhealthy instance is found, terminates and launches a new one
> Manual Scaling
> Specify a change in maximum, min or desired of auto scaling group
> Auto scaling then manages the process of creating or terminating instances to maintain the new capacity.
> Scale based on schedule
> Based on a predictable schedule
> Action are performed autoamtically as a function of time and date.
> Scale based on demand
> Define parameters that control auto scaling process.
> Such as enlarging fleet when cpu hits 80% on average across instances for 15 minutes.
> Useful when you want to scale in resposne to changing conditions when you dont know when those conditions will change.
---------------------------------------------------------------------------------------------------------------------------
CREATE A LAUNCH CONFIGURATION:
Go to: EC2
> Auto Scaling -> Auto Scaling Groups
> 'Create Auto Scaling Group'
> Select 'Launch Configuration' -> 'Create a new Launch Configuration'
(An auto scaling group contains a collection of EC2 instances that share similar characteristics and a treated as a logical grouping.)
In the lab the Amazon Linux 2 AMI was selected - with T2.Micro used as the instance type.
> Give the Launch Configuration a name 'Lab-Configuration'
> Explode the 'Advanced Details'
> IP Address Type -> Assign a public IP address to every insance (selected)
> Add storage
> Configure Security Group - select an existing one in the labs case (usually you would select your own)
AT THIS POINT THE LAUNCH CONFIGURATION IS COMPLETE AND WE NOW NEED TO CREATE AN AUTO SCALING GROUP
---------------------------------------------------------------------------------------------------------------------------
CREATE AN AUTO SCALING GROUP
The launch configuration defines WHAT should be launched. The Auto Scaling group defines HOW MANY instances to launch and WHERE to launch
them within the network.
---------------------------------------------------------------------------------------------------------------------------
HOW TO TEST AUTO SCALING:
> Go to Instances
> Terminate an instance
Click on 'Auto Scaling Groups'
> Click instances tab - you should see a new instance appear.
( At first this will show as 'Unhealthy' then proceed to bring up a new instance ).
Cost: No additional cost : you just pay for the compute (EC2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment