SlideShare una empresa de Scribd logo
1 de 64
Descargar para leer sin conexión
© 2015, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Michael Hanisch, AWS Solutions Architecture
October 2015
CMP201
All You Need to Know
About Auto Scaling
What to Expect from the Session
- Basic introduction to Auto Scaling
- Using Scaling Policies
- Controlling launch and termination of EC2 instances
Auto Scaling – The Basics
instance instance
Availability Zone bAvailability Zone a
Elastic Load
Balancing
instance instanceinstance instance
Availability Zone bAvailability Zone a
Elastic Load
Balancing
instance instanceinstance instance
Auto Scaling group
Minimum = 2 Maximum = 10
Desired # of instances = 4
Availability Zone bAvailability Zone a
Elastic Load
Balancing
Auto Scaling Groups
- Always keep minimum number of instances running
- Launch or terminate instances to meet desired capacity
- Never start more than maximum number of instances
- Keeps capacity balanced across AZs
instance instanceinstance instance
Auto Scaling group
Minimum = 2 Maximum = 10
Desired # of instances = 6
Availability Zone bAvailability Zone a
Elastic Load
Balancing
instance instanceinstance instance
Auto Scaling group
Minimum = 2 Maximum = 10
Desired # of instances = 6
instanceinstance
Availability Zone bAvailability Zone a
Elastic Load
Balancing
Launch Configurations
Determine what is going to be launched:
- EC2 instance type & size
- Amazon Machine Image (AMI)
- Security groups, SSH keys, IAM instance profile
- User data
…
Bootstrapping
Installation & setup needs to be fully automated:
- Use Amazon Machine Image (AMI) with all required
configuration & software (“golden image”)
- Base AMI + install code & configuration as needed
- Via Userdata
- Via Chef/Puppet/Ansible/…
- Using AWS CodeDeploy
…
Bootstrapping
#!/bin/bash
yum –y update;
yum install –y ruby; yum install –y aws-cli;
cd /home/ec2-user;
aws s3 cp s3://aws-codedeploy-us-east-1/latest/ 
install . --region us-east-1;
chmod +x ./install;
./install auto;
instance instanceinstance instance
Auto Scaling group
Minimum = 2 Maximum = 10
Desired # of instances = 6
instanceinstance
Availability Zone bAvailability Zone a
Elastic Load
Balancing
instance instanceinstance instance
Auto Scaling group
Minimum = 2 Maximum = 10
Desired # of instances = 5
instanceinstance
Availability Zone bAvailability Zone a
Elastic Load
Balancing
instance instanceinstance instance
Auto Scaling group
Minimum = 2 Maximum = 10
Desired # of instances = 5
instance
Availability Zone bAvailability Zone a
Elastic Load
Balancing
Termination Policies
Determine which instances are terminated first:
- Longest running
- Oldest launch configuration
- Closest to full billing hour
But: rebalancing of capacity across AZs takes precedence!
Scaling Plans
Determine when the Auto Scaling group will scale in or out:
desired capacity > current capacity: launch instances
desired capacity < current capacity: terminate instances
Scaling Plans
- Default: ensure current capacity of healthy instances
remains within boundaries (never less than minimum)
- ‘Manual scaling’: modify desired capacity (via API,
console, CLI) to trigger a scaling event
- Scheduled: scale in / out based on timed events
- Dynamic scaling: scale on Amazon CloudWatch metrics
Auto Scaling Concepts
Launch Configuration
• Auto Scaling groups
use a launch
configuration to launch
EC2 instances.
• Provides information
about the AMI and
EC2 instance
types/size
Scaling Plan
• A scaling plan tells
Auto Scaling when and
how to scale.
• Create a scaling plan
based on the
occurrence of
specified conditions
(dynamic scaling) or
create a plan based on
a specific schedule.
Auto Scaling Groups
• EC2 instances are
managed by Auto
Scaling groups.
• Create Auto Scaling
groups by defining the
minimum, maximum,
and, optionally, the
desired number of
running EC2
instances.
Integration with
Amazon Elastic Load Balancing
Load Balance your Auto Scaling Group
- Distribute incoming web traffic automatically.
- Single point of entry for your application.
- Sends data about your load balancers and EC2 instances to
Amazon CloudWatch.
- Use Elastic Load Balancing metrics to scale your application.
- Use connection draining to wait for the in-flight requests to
complete.
Elastic Load
Balancing
Load Balance your Auto Scaling Group
- Configure your Auto Scaling Group to work with one or more
Elastic Load Balancers
- Automatically registers new instances,
deregisters on termination
- Use ELB health checks in your Auto Scaling Group
- Use Elastic Load Balancing metrics in scaling policies
Elastic Load
Balancing
Benefits of Auto Scaling
Elasticity:
Automatically adapt
capacity to demand
Availability & Reliability
Health Checks
- Performed periodically
- Instances are marked as unhealthy or healthy
- Unhealthy instances are terminated and replaced
(if new number of instances < minimum or < desired capacity)
Health Checks
- EC2 instance status:
Instance is unhealthy when instance state != ‘running’
or system health check == ‘impaired’
- ELB health checks:
instance is unhealthy when ELB health check results in
“OutOfService” (or EC2 health check failed)
- Manual: mark individual instances as ‘unhealthy’
Instance unhealthy when marked as such or EC2 health check
failed. Use to integrate with external monitoring systems.
instance instanceinstance instance
Auto Scaling group
Minimum = 2 Maximum = 10
Desired # of instances = 6
instanceinstance
Availability Zone bAvailability Zone a
Elastic Load
Balancing
Unhealthy Instances Get Replaced…
instance instanceinstance instance
Auto Scaling group
Minimum = 2 Maximum = 10
Desired # of instances = 6
instanceinstance
Availability Zone bAvailability Zone a
Elastic Load
Balancing
Unhealthy Instances Get Replaced…
instance instanceinstance instance
Auto Scaling group
Minimum = 2 Maximum = 10
Desired # of instances = 6
instanceinstance
Availability Zone bAvailability Zone a
Elastic Load
Balancing
Unhealthy Instances Get Replaced…
instance instanceinstance instance
Auto Scaling group
Minimum = 2 Maximum = 10
Desired # of instances = 6
instanceinstance
Availability Zone bAvailability Zone a
Elastic Load
Balancing
…In a Different AZ if Necessary
instanceinstance instanceinstance
Auto Scaling group
Minimum = 2 Maximum = 10
Desired # of instances = 6
instance
Availability Zone bAvailability Zone a
instance
Elastic Load
Balancing
Benefits of Auto Scaling
Elastic:
Automatically adapt
capacity to demand
Reliable:
Counteract failures
of instances or AZs
Scaling Policies
Scaling Policies
Can change capacity of the group in 3 different ways:
- Set fixed capacity, e.g., desired capacity = 4 instances
- Add / remove fixed number of instances, e.g., + 2
- Add / remove percentage of existing capacity, e.g. +20%
Scaling on a Schedule
Scaling on a Schedule Elastic Load
Balancing
Auto Scaling group
cron-like syntax for
recurring scaling
events
Schedule
individual events
(up to 135 events
per group)
Auto Scaling CLI & SDK only!
Not available in AWS management console
Set min / max / desired capacity
Elastic Load
Balancing
Dynamic Scaling Policies
Dynamic Scaling Policies
Trigger scaling events based on demand:
- Demand is measured based on metrics
- Changes in metrics can be mapped to scaling policies
Amazon CloudWatch
Amazon CloudWatch: A web service that enables you to monitor and
manage various metrics, and configure alarm actions based on data
from those metrics.
A metric is a variable that you want to monitor, e.g., CPU usage or
incoming network traffic.
A CloudWatch alarm is an object that monitors a single metric over a
specific period.
The alarm changes its state when the value of the metric breaches a
defined range and maintains the change for a specified number of
periods.
CloudWatch
Auto Scaling group
Collect metrics
Alarm fires when
threshold is crossed
Amazon CloudWatch can aggregate metrics across pre-defined dimensions, e.g.,
aggregate average CPU utilization of all EC2 instances in an Auto Scaling group.
Auto Scaling
Alarm is
connected to
Auto Scaling
policy
Scaling event is triggered
How Alarms Work
Elastic Load
Balancing
0
10
20
30
40
50
60
70
80
90
0:01 0:02 0:03 0:04 0:05 0:06 0:07 0:08 0:09 0:10 0:11 0:12 0:13
CPU Utilization
CPU Utilization
Evaluation Period(s)Scale Out Cooldown
Alarm Fires
No additional alarms or scaling
actions during this time!
0
10
20
30
40
50
60
70
80
90
0:01 0:02 0:03 0:04 0:05 0:06 0:07 0:08 0:09 0:10 0:11 0:12 0:13
CPU Utilization
CPU Utilization
Alarm Fires (too late?)
Step Scaling Policies
Step Scaling Policies
Define multiple steps in the same policy.
The appropriate scaling step is selected based on the value of
the metric that triggered the alarm, i.e., based on the magnitude
of the breach.
Step scaling policies are evaluated continuously.
No locking – alarms keep getting evaluated even while scaling.
Step Scaling Policies
Define multiple steps in the same policy.
The appropriate scaling step is selected based on the value of
the metric, i.e. based on the magnitude of the breach.
Step scaling policies are evaluated continuously.
0
10
20
30
40
50
60
70
80
90
0:01 0:02 0:03 0:04 0:05 0:06 0:07 0:08 0:09 0:10 0:11 0:12 0:13
CPU Utilization
CPU Utilization
Alarm Fires
Simple scaling policies
- Reaction always the same,
independent of size of breach
- Locks the Auto Scaling group
when a scaling action is run,
i.e., single event at a time
- Evaluates metric only when no
scaling action ongoing
- Cooldown takes effect after
scaling action is complete
Pros & Cons
Step scaling policies
- Continuously evaluates metrics
- “Instant” reaction
- Does not ‘lock’ the Auto
Scaling group while action is
evaluated
- Cooldown not supported (use
‘warmup’ period instead)
When in doubt, prefer
step scaling policies.
The Instance Lifecycle
Instance Lifecycle
Scale Out
Event
Instance launching:
Pending
InService
TerminatingTerminated
Scale In
Event
Health
check
failed
Lifecycle Hooks
Why? – Common Use Cases
• Assign Elastic IP address on launch
• Register new instances with DNS, message queues,…
• Pull down log files before instance is terminated
• Investigate issues with an instance before terminating it
• …
Instance Lifecycle
Instance launching:
Pending
InService
TerminatingTerminated
Pending:WAIT
Terminating:WAIT
How?
1. Create a notification target– either an Amazon SQS
queue or Amazon SNS topic.
2. Create an IAM role that allows Auto Scaling to access
the notification queue / topic.
3. Associate the lifecycle hook with the Auto Scaling
group, role and notification target.
4. Code the lifecycle hook’s action
Sample Notification
Service: Auto Scaling
Time: 2015-09-21T21:53:43.989Z
RequestId: 52e21eba-718a-43a7-81a8-3b379054cba6
LifecycleActionToken: 979c0f97-80c5-44bd-a2b6-5a8aae339f35
AccountId: XXXXXXXXX
AutoScalingGroupName: cmp201
LifecycleHookName: do-something-on-launch
EC2InstanceId: i-XXXXX
LifecycleTransition: autoscaling:EC2_INSTANCE_LAUNCHING
NotificationMetadata: null
Writing a Lifecycle Hook Action
1. Extract token, instanceID and other params.
2. Remember the token – you're going to need it!
3. Do stuff…
4. Call CompleteLifecycleAction (with the token) to signal
that you’re done! (or send heartbeat if you need more
time)
Amazon SNS Notifications
Lifecycle hooks
- Executed before taking a new
instance into service /
terminating it
- Put instances into a WAIT
state
Auto Scaling SNS notifications
- Notifications get sent after an
instance has entered
“InService” or “Terminated”
state, respectively
Instance Lifecycle
Instance launching:
Pending
InService
TerminatingTerminated
Entering Standby…
Standby
Benefits of Auto Scaling
Elastic:
Automatically adapt
capacity to demand
Reliable:
Counteract failures
of instances or AZs
Customizable:
With bootstrapping
& lifecycle hooks
Outlook
Outlook
• Integrate Auto Scaling and EC2 Spot Instances to save $
• Handle rolling deployments across Auto Scaling groups
Thank you!
Remember to complete
your evaluations!

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Deploy and Govern at Scale with AWS Control Tower
Deploy and Govern at Scale with AWS Control TowerDeploy and Govern at Scale with AWS Control Tower
Deploy and Govern at Scale with AWS Control Tower
 
AWS 101
AWS 101AWS 101
AWS 101
 
AWS Elastic Load Balancing for AWS Architect & SysOps Certification
AWS Elastic Load Balancing for AWS Architect & SysOps CertificationAWS Elastic Load Balancing for AWS Architect & SysOps Certification
AWS Elastic Load Balancing for AWS Architect & SysOps Certification
 
AWS Technical Essentials Day
AWS Technical Essentials DayAWS Technical Essentials Day
AWS Technical Essentials Day
 
AWS Cloud Watch
AWS Cloud WatchAWS Cloud Watch
AWS Cloud Watch
 
AWS ELB
AWS ELBAWS ELB
AWS ELB
 
Deep Dive on AWS Lambda
Deep Dive on AWS LambdaDeep Dive on AWS Lambda
Deep Dive on AWS Lambda
 
AWS AutoScaling
AWS AutoScalingAWS AutoScaling
AWS AutoScaling
 
AWS IAM Introduction
AWS IAM IntroductionAWS IAM Introduction
AWS IAM Introduction
 
AWS SQS SNS
AWS SQS SNSAWS SQS SNS
AWS SQS SNS
 
Introduction to AWS Organizations
Introduction to AWS OrganizationsIntroduction to AWS Organizations
Introduction to AWS Organizations
 
Introduction to Amazon EC2
Introduction to Amazon EC2Introduction to Amazon EC2
Introduction to Amazon EC2
 
Introduction to Amazon EC2
Introduction to Amazon EC2Introduction to Amazon EC2
Introduction to Amazon EC2
 
Introduction to Amazon Web Services (AWS)
Introduction to Amazon Web Services (AWS)Introduction to Amazon Web Services (AWS)
Introduction to Amazon Web Services (AWS)
 
Amazon Route 53 - Webinar Presentation 9.16.2015
Amazon Route 53 - Webinar Presentation 9.16.2015Amazon Route 53 - Webinar Presentation 9.16.2015
Amazon Route 53 - Webinar Presentation 9.16.2015
 
Introduction to Amazon EC2
Introduction to Amazon EC2Introduction to Amazon EC2
Introduction to Amazon EC2
 
Identity and Access Management: The First Step in AWS Security
Identity and Access Management: The First Step in AWS SecurityIdentity and Access Management: The First Step in AWS Security
Identity and Access Management: The First Step in AWS Security
 
What is Cloud Computing with Amazon Web Services?
What is Cloud Computing with Amazon Web Services?What is Cloud Computing with Amazon Web Services?
What is Cloud Computing with Amazon Web Services?
 
AWS networking fundamentals
AWS networking fundamentalsAWS networking fundamentals
AWS networking fundamentals
 
AWS Control Tower
AWS Control TowerAWS Control Tower
AWS Control Tower
 

Destacado

Destacado (20)

AWS re:Invent 2016: Auto Scaling – the Fleet Management Solution for Planet E...
AWS re:Invent 2016: Auto Scaling – the Fleet Management Solution for Planet E...AWS re:Invent 2016: Auto Scaling – the Fleet Management Solution for Planet E...
AWS re:Invent 2016: Auto Scaling – the Fleet Management Solution for Planet E...
 
All you need to know about Auto scaling - Pop-up Loft
All you need to know about Auto scaling - Pop-up LoftAll you need to know about Auto scaling - Pop-up Loft
All you need to know about Auto scaling - Pop-up Loft
 
AWS re:Invent 2016: Elastic Load Balancing Deep Dive and Best Practices (NET403)
AWS re:Invent 2016: Elastic Load Balancing Deep Dive and Best Practices (NET403)AWS re:Invent 2016: Elastic Load Balancing Deep Dive and Best Practices (NET403)
AWS re:Invent 2016: Elastic Load Balancing Deep Dive and Best Practices (NET403)
 
Amazon S3 Masterclass
Amazon S3 MasterclassAmazon S3 Masterclass
Amazon S3 Masterclass
 
Intro to AWS: EC2 & Compute Services
Intro to AWS: EC2 & Compute ServicesIntro to AWS: EC2 & Compute Services
Intro to AWS: EC2 & Compute Services
 
Autoscaling Best Practices
Autoscaling Best PracticesAutoscaling Best Practices
Autoscaling Best Practices
 
AWS re:Invent 2016: IAM Best Practices to Live By (SAC317)
AWS re:Invent 2016: IAM Best Practices to Live By (SAC317)AWS re:Invent 2016: IAM Best Practices to Live By (SAC317)
AWS re:Invent 2016: IAM Best Practices to Live By (SAC317)
 
AWS re:Invent 2016: Deep Dive on Amazon Elastic Block Store (STG301)
AWS re:Invent 2016: Deep Dive on Amazon Elastic Block Store (STG301)AWS re:Invent 2016: Deep Dive on Amazon Elastic Block Store (STG301)
AWS re:Invent 2016: Deep Dive on Amazon Elastic Block Store (STG301)
 
(SDD423) Elastic Load Balancing Deep Dive and Best Practices | AWS re:Invent ...
(SDD423) Elastic Load Balancing Deep Dive and Best Practices | AWS re:Invent ...(SDD423) Elastic Load Balancing Deep Dive and Best Practices | AWS re:Invent ...
(SDD423) Elastic Load Balancing Deep Dive and Best Practices | AWS re:Invent ...
 
Amazon EFS
Amazon EFSAmazon EFS
Amazon EFS
 
Think Big Analytics Corporate Deck Hadoop Summit June 2011
Think Big Analytics Corporate Deck Hadoop Summit June 2011Think Big Analytics Corporate Deck Hadoop Summit June 2011
Think Big Analytics Corporate Deck Hadoop Summit June 2011
 
AWS November Webinar Series - Architectural Patterns & Best Practices for Big...
AWS November Webinar Series - Architectural Patterns & Best Practices for Big...AWS November Webinar Series - Architectural Patterns & Best Practices for Big...
AWS November Webinar Series - Architectural Patterns & Best Practices for Big...
 
(SOV202) Choosing Among AWS Managed Database Services | AWS re:Invent 2014
(SOV202) Choosing Among AWS Managed Database Services | AWS re:Invent 2014(SOV202) Choosing Among AWS Managed Database Services | AWS re:Invent 2014
(SOV202) Choosing Among AWS Managed Database Services | AWS re:Invent 2014
 
Weaving Containers in Amazon's ECA
Weaving Containers in Amazon's ECAWeaving Containers in Amazon's ECA
Weaving Containers in Amazon's ECA
 
Practical Steps to Hackproofing AWS
Practical Steps to Hackproofing AWSPractical Steps to Hackproofing AWS
Practical Steps to Hackproofing AWS
 
(DAT302) Relational Database Management Systems in the Cloud
(DAT302) Relational Database Management Systems in the Cloud(DAT302) Relational Database Management Systems in the Cloud
(DAT302) Relational Database Management Systems in the Cloud
 
(SPOT208) How to Sponsor a Diversity Circle in a Tech Workplace
(SPOT208) How to Sponsor a Diversity Circle in a Tech Workplace(SPOT208) How to Sponsor a Diversity Circle in a Tech Workplace
(SPOT208) How to Sponsor a Diversity Circle in a Tech Workplace
 
Design Patterns for Developers - Technical 201
Design Patterns for Developers - Technical 201Design Patterns for Developers - Technical 201
Design Patterns for Developers - Technical 201
 
20150109 - AWS BlackBelt - IAM (Korean)
20150109 - AWS BlackBelt - IAM (Korean)20150109 - AWS BlackBelt - IAM (Korean)
20150109 - AWS BlackBelt - IAM (Korean)
 
Intro to AWS: Amazon EC2 and Compute Services
Intro to AWS: Amazon EC2 and Compute ServicesIntro to AWS: Amazon EC2 and Compute Services
Intro to AWS: Amazon EC2 and Compute Services
 

Similar a (CMP201) All You Need To Know About Auto Scaling

Similar a (CMP201) All You Need To Know About Auto Scaling (20)

Automating Management of Amazon EC2 Instances with Auto Scaling - March 2017 ...
Automating Management of Amazon EC2 Instances with Auto Scaling - March 2017 ...Automating Management of Amazon EC2 Instances with Auto Scaling - March 2017 ...
Automating Management of Amazon EC2 Instances with Auto Scaling - March 2017 ...
 
How Does Amazon EC2 Auto Scaling Work
How Does Amazon EC2 Auto Scaling WorkHow Does Amazon EC2 Auto Scaling Work
How Does Amazon EC2 Auto Scaling Work
 
AWS Public Sector Symposium 2014 Canberra | Managing Seasonal Workloads on AWS
AWS Public Sector Symposium 2014 Canberra | Managing Seasonal Workloads on AWS AWS Public Sector Symposium 2014 Canberra | Managing Seasonal Workloads on AWS
AWS Public Sector Symposium 2014 Canberra | Managing Seasonal Workloads on AWS
 
AWS APAC Webinar Week - Maintaining Performance & Availability While Lowering...
AWS APAC Webinar Week - Maintaining Performance & Availability While Lowering...AWS APAC Webinar Week - Maintaining Performance & Availability While Lowering...
AWS APAC Webinar Week - Maintaining Performance & Availability While Lowering...
 
Running Lean Architectures: How to Optimize for Cost Efficiency
Running Lean Architectures: How to Optimize for Cost Efficiency Running Lean Architectures: How to Optimize for Cost Efficiency
Running Lean Architectures: How to Optimize for Cost Efficiency
 
Optimizing Costs and Efficiency of AWS Services
Optimizing Costs and Efficiency of AWS Services Optimizing Costs and Efficiency of AWS Services
Optimizing Costs and Efficiency of AWS Services
 
Using AWS CloudWatch Custom Metrics and EC2 Auto Scaling -VSocial Infrastructure
Using AWS CloudWatch Custom Metrics and EC2 Auto Scaling -VSocial InfrastructureUsing AWS CloudWatch Custom Metrics and EC2 Auto Scaling -VSocial Infrastructure
Using AWS CloudWatch Custom Metrics and EC2 Auto Scaling -VSocial Infrastructure
 
Cost Optimisation at Scale - Business
Cost Optimisation at Scale - BusinessCost Optimisation at Scale - Business
Cost Optimisation at Scale - Business
 
#lspe Q1 2013 dynamically scaling netflix in the cloud
#lspe Q1 2013   dynamically scaling netflix in the cloud#lspe Q1 2013   dynamically scaling netflix in the cloud
#lspe Q1 2013 dynamically scaling netflix in the cloud
 
Cloud Economics
Cloud EconomicsCloud Economics
Cloud Economics
 
오토스케일링 제대로 활용하기 (김일호) - AWS 웨비나 시리즈 2015
오토스케일링 제대로 활용하기 (김일호) - AWS 웨비나 시리즈 2015오토스케일링 제대로 활용하기 (김일호) - AWS 웨비나 시리즈 2015
오토스케일링 제대로 활용하기 (김일호) - AWS 웨비나 시리즈 2015
 
Autoscaler architecture of apache stratos 4.0.0
Autoscaler architecture of apache stratos 4.0.0Autoscaler architecture of apache stratos 4.0.0
Autoscaler architecture of apache stratos 4.0.0
 
Deep Dive on Microservices and Amazon ECS
Deep Dive on Microservices and Amazon ECSDeep Dive on Microservices and Amazon ECS
Deep Dive on Microservices and Amazon ECS
 
AWS - Autoscaling Fundamentals
AWS - Autoscaling FundamentalsAWS - Autoscaling Fundamentals
AWS - Autoscaling Fundamentals
 
ENT314 Automate Best Practices and Operational Health for Your AWS Resources
ENT314 Automate Best Practices and Operational Health for Your AWS ResourcesENT314 Automate Best Practices and Operational Health for Your AWS Resources
ENT314 Automate Best Practices and Operational Health for Your AWS Resources
 
AWS AutoScalling- Tech Talks Maio 2019
AWS AutoScalling- Tech Talks Maio 2019AWS AutoScalling- Tech Talks Maio 2019
AWS AutoScalling- Tech Talks Maio 2019
 
AutoScaling and Drupal
AutoScaling and DrupalAutoScaling and Drupal
AutoScaling and Drupal
 
Cost Optimization on AWS - Pop-up Loft Tel Aviv
Cost Optimization on AWS - Pop-up Loft Tel AvivCost Optimization on AWS - Pop-up Loft Tel Aviv
Cost Optimization on AWS - Pop-up Loft Tel Aviv
 
ENT314 Automate Best Practices and Operational Health for Your AWS Resources
ENT314 Automate Best Practices and Operational Health for Your AWS ResourcesENT314 Automate Best Practices and Operational Health for Your AWS Resources
ENT314 Automate Best Practices and Operational Health for Your AWS Resources
 
Automate Best Practices and Operational Health for your AWS resources
Automate Best Practices and Operational Health for your AWS resourcesAutomate Best Practices and Operational Health for your AWS resources
Automate Best Practices and Operational Health for your AWS resources
 

Más de Amazon Web Services

Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
Amazon Web Services
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
Amazon Web Services
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
Amazon Web Services
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
Amazon Web Services
 

Más de Amazon Web Services (20)

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS Fargate
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWS
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot
 
Open banking as a service
Open banking as a serviceOpen banking as a service
Open banking as a service
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
 
Computer Vision con AWS
Computer Vision con AWSComputer Vision con AWS
Computer Vision con AWS
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatare
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e web
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
 
Fundraising Essentials
Fundraising EssentialsFundraising Essentials
Fundraising Essentials
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container Service
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

(CMP201) All You Need To Know About Auto Scaling

  • 1. © 2015, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Michael Hanisch, AWS Solutions Architecture October 2015 CMP201 All You Need to Know About Auto Scaling
  • 2. What to Expect from the Session - Basic introduction to Auto Scaling - Using Scaling Policies - Controlling launch and termination of EC2 instances
  • 3. Auto Scaling – The Basics
  • 4. instance instance Availability Zone bAvailability Zone a Elastic Load Balancing
  • 5. instance instanceinstance instance Availability Zone bAvailability Zone a Elastic Load Balancing
  • 6. instance instanceinstance instance Auto Scaling group Minimum = 2 Maximum = 10 Desired # of instances = 4 Availability Zone bAvailability Zone a Elastic Load Balancing
  • 7. Auto Scaling Groups - Always keep minimum number of instances running - Launch or terminate instances to meet desired capacity - Never start more than maximum number of instances - Keeps capacity balanced across AZs
  • 8. instance instanceinstance instance Auto Scaling group Minimum = 2 Maximum = 10 Desired # of instances = 6 Availability Zone bAvailability Zone a Elastic Load Balancing
  • 9. instance instanceinstance instance Auto Scaling group Minimum = 2 Maximum = 10 Desired # of instances = 6 instanceinstance Availability Zone bAvailability Zone a Elastic Load Balancing
  • 10. Launch Configurations Determine what is going to be launched: - EC2 instance type & size - Amazon Machine Image (AMI) - Security groups, SSH keys, IAM instance profile - User data …
  • 11. Bootstrapping Installation & setup needs to be fully automated: - Use Amazon Machine Image (AMI) with all required configuration & software (“golden image”) - Base AMI + install code & configuration as needed - Via Userdata - Via Chef/Puppet/Ansible/… - Using AWS CodeDeploy …
  • 12. Bootstrapping #!/bin/bash yum –y update; yum install –y ruby; yum install –y aws-cli; cd /home/ec2-user; aws s3 cp s3://aws-codedeploy-us-east-1/latest/ install . --region us-east-1; chmod +x ./install; ./install auto;
  • 13. instance instanceinstance instance Auto Scaling group Minimum = 2 Maximum = 10 Desired # of instances = 6 instanceinstance Availability Zone bAvailability Zone a Elastic Load Balancing
  • 14. instance instanceinstance instance Auto Scaling group Minimum = 2 Maximum = 10 Desired # of instances = 5 instanceinstance Availability Zone bAvailability Zone a Elastic Load Balancing
  • 15. instance instanceinstance instance Auto Scaling group Minimum = 2 Maximum = 10 Desired # of instances = 5 instance Availability Zone bAvailability Zone a Elastic Load Balancing
  • 16. Termination Policies Determine which instances are terminated first: - Longest running - Oldest launch configuration - Closest to full billing hour But: rebalancing of capacity across AZs takes precedence!
  • 17. Scaling Plans Determine when the Auto Scaling group will scale in or out: desired capacity > current capacity: launch instances desired capacity < current capacity: terminate instances
  • 18. Scaling Plans - Default: ensure current capacity of healthy instances remains within boundaries (never less than minimum) - ‘Manual scaling’: modify desired capacity (via API, console, CLI) to trigger a scaling event - Scheduled: scale in / out based on timed events - Dynamic scaling: scale on Amazon CloudWatch metrics
  • 19. Auto Scaling Concepts Launch Configuration • Auto Scaling groups use a launch configuration to launch EC2 instances. • Provides information about the AMI and EC2 instance types/size Scaling Plan • A scaling plan tells Auto Scaling when and how to scale. • Create a scaling plan based on the occurrence of specified conditions (dynamic scaling) or create a plan based on a specific schedule. Auto Scaling Groups • EC2 instances are managed by Auto Scaling groups. • Create Auto Scaling groups by defining the minimum, maximum, and, optionally, the desired number of running EC2 instances.
  • 21. Load Balance your Auto Scaling Group - Distribute incoming web traffic automatically. - Single point of entry for your application. - Sends data about your load balancers and EC2 instances to Amazon CloudWatch. - Use Elastic Load Balancing metrics to scale your application. - Use connection draining to wait for the in-flight requests to complete. Elastic Load Balancing
  • 22. Load Balance your Auto Scaling Group - Configure your Auto Scaling Group to work with one or more Elastic Load Balancers - Automatically registers new instances, deregisters on termination - Use ELB health checks in your Auto Scaling Group - Use Elastic Load Balancing metrics in scaling policies Elastic Load Balancing
  • 23. Benefits of Auto Scaling Elasticity: Automatically adapt capacity to demand
  • 25. Health Checks - Performed periodically - Instances are marked as unhealthy or healthy - Unhealthy instances are terminated and replaced (if new number of instances < minimum or < desired capacity)
  • 26. Health Checks - EC2 instance status: Instance is unhealthy when instance state != ‘running’ or system health check == ‘impaired’ - ELB health checks: instance is unhealthy when ELB health check results in “OutOfService” (or EC2 health check failed) - Manual: mark individual instances as ‘unhealthy’ Instance unhealthy when marked as such or EC2 health check failed. Use to integrate with external monitoring systems.
  • 27. instance instanceinstance instance Auto Scaling group Minimum = 2 Maximum = 10 Desired # of instances = 6 instanceinstance Availability Zone bAvailability Zone a Elastic Load Balancing
  • 28. Unhealthy Instances Get Replaced… instance instanceinstance instance Auto Scaling group Minimum = 2 Maximum = 10 Desired # of instances = 6 instanceinstance Availability Zone bAvailability Zone a Elastic Load Balancing
  • 29. Unhealthy Instances Get Replaced… instance instanceinstance instance Auto Scaling group Minimum = 2 Maximum = 10 Desired # of instances = 6 instanceinstance Availability Zone bAvailability Zone a Elastic Load Balancing
  • 30. Unhealthy Instances Get Replaced… instance instanceinstance instance Auto Scaling group Minimum = 2 Maximum = 10 Desired # of instances = 6 instanceinstance Availability Zone bAvailability Zone a Elastic Load Balancing
  • 31. …In a Different AZ if Necessary instanceinstance instanceinstance Auto Scaling group Minimum = 2 Maximum = 10 Desired # of instances = 6 instance Availability Zone bAvailability Zone a instance Elastic Load Balancing
  • 32. Benefits of Auto Scaling Elastic: Automatically adapt capacity to demand Reliable: Counteract failures of instances or AZs
  • 34. Scaling Policies Can change capacity of the group in 3 different ways: - Set fixed capacity, e.g., desired capacity = 4 instances - Add / remove fixed number of instances, e.g., + 2 - Add / remove percentage of existing capacity, e.g. +20%
  • 35. Scaling on a Schedule
  • 36. Scaling on a Schedule Elastic Load Balancing Auto Scaling group cron-like syntax for recurring scaling events Schedule individual events (up to 135 events per group) Auto Scaling CLI & SDK only! Not available in AWS management console Set min / max / desired capacity Elastic Load Balancing
  • 38. Dynamic Scaling Policies Trigger scaling events based on demand: - Demand is measured based on metrics - Changes in metrics can be mapped to scaling policies
  • 39. Amazon CloudWatch Amazon CloudWatch: A web service that enables you to monitor and manage various metrics, and configure alarm actions based on data from those metrics. A metric is a variable that you want to monitor, e.g., CPU usage or incoming network traffic. A CloudWatch alarm is an object that monitors a single metric over a specific period. The alarm changes its state when the value of the metric breaches a defined range and maintains the change for a specified number of periods. CloudWatch
  • 40. Auto Scaling group Collect metrics Alarm fires when threshold is crossed Amazon CloudWatch can aggregate metrics across pre-defined dimensions, e.g., aggregate average CPU utilization of all EC2 instances in an Auto Scaling group. Auto Scaling Alarm is connected to Auto Scaling policy Scaling event is triggered How Alarms Work Elastic Load Balancing
  • 41. 0 10 20 30 40 50 60 70 80 90 0:01 0:02 0:03 0:04 0:05 0:06 0:07 0:08 0:09 0:10 0:11 0:12 0:13 CPU Utilization CPU Utilization Evaluation Period(s)Scale Out Cooldown Alarm Fires No additional alarms or scaling actions during this time!
  • 42. 0 10 20 30 40 50 60 70 80 90 0:01 0:02 0:03 0:04 0:05 0:06 0:07 0:08 0:09 0:10 0:11 0:12 0:13 CPU Utilization CPU Utilization Alarm Fires (too late?)
  • 44. Step Scaling Policies Define multiple steps in the same policy. The appropriate scaling step is selected based on the value of the metric that triggered the alarm, i.e., based on the magnitude of the breach. Step scaling policies are evaluated continuously. No locking – alarms keep getting evaluated even while scaling.
  • 45. Step Scaling Policies Define multiple steps in the same policy. The appropriate scaling step is selected based on the value of the metric, i.e. based on the magnitude of the breach. Step scaling policies are evaluated continuously.
  • 46. 0 10 20 30 40 50 60 70 80 90 0:01 0:02 0:03 0:04 0:05 0:06 0:07 0:08 0:09 0:10 0:11 0:12 0:13 CPU Utilization CPU Utilization Alarm Fires
  • 47. Simple scaling policies - Reaction always the same, independent of size of breach - Locks the Auto Scaling group when a scaling action is run, i.e., single event at a time - Evaluates metric only when no scaling action ongoing - Cooldown takes effect after scaling action is complete Pros & Cons Step scaling policies - Continuously evaluates metrics - “Instant” reaction - Does not ‘lock’ the Auto Scaling group while action is evaluated - Cooldown not supported (use ‘warmup’ period instead)
  • 48. When in doubt, prefer step scaling policies.
  • 50. Instance Lifecycle Scale Out Event Instance launching: Pending InService TerminatingTerminated Scale In Event Health check failed
  • 52. Why? – Common Use Cases • Assign Elastic IP address on launch • Register new instances with DNS, message queues,… • Pull down log files before instance is terminated • Investigate issues with an instance before terminating it • …
  • 54. How? 1. Create a notification target– either an Amazon SQS queue or Amazon SNS topic. 2. Create an IAM role that allows Auto Scaling to access the notification queue / topic. 3. Associate the lifecycle hook with the Auto Scaling group, role and notification target. 4. Code the lifecycle hook’s action
  • 55. Sample Notification Service: Auto Scaling Time: 2015-09-21T21:53:43.989Z RequestId: 52e21eba-718a-43a7-81a8-3b379054cba6 LifecycleActionToken: 979c0f97-80c5-44bd-a2b6-5a8aae339f35 AccountId: XXXXXXXXX AutoScalingGroupName: cmp201 LifecycleHookName: do-something-on-launch EC2InstanceId: i-XXXXX LifecycleTransition: autoscaling:EC2_INSTANCE_LAUNCHING NotificationMetadata: null
  • 56. Writing a Lifecycle Hook Action 1. Extract token, instanceID and other params. 2. Remember the token – you're going to need it! 3. Do stuff… 4. Call CompleteLifecycleAction (with the token) to signal that you’re done! (or send heartbeat if you need more time)
  • 58. Lifecycle hooks - Executed before taking a new instance into service / terminating it - Put instances into a WAIT state Auto Scaling SNS notifications - Notifications get sent after an instance has entered “InService” or “Terminated” state, respectively
  • 60. Benefits of Auto Scaling Elastic: Automatically adapt capacity to demand Reliable: Counteract failures of instances or AZs Customizable: With bootstrapping & lifecycle hooks
  • 62. Outlook • Integrate Auto Scaling and EC2 Spot Instances to save $ • Handle rolling deployments across Auto Scaling groups