심화 웨비나 시리즈 | 7 번째 강연
2015년 7월 9일 목요일 | 오전 10시
http://aws.amazon.com/ko
오토스케일링 제대로 활용하기
김일호, Solutions Architect
이번 웨비나 에서 들으실 내용..
오토스케일링(Autho-scaling)은 AWS 클라우드를 통해 확장성 높은
서비스와 아키텍쳐를 구성하는 가장 중요한 방식 중 하나입니다. 본
강연에서는 효과적인 클라우드 인프라 사용 패턴을 제공하기 위한
오토 스케일링에 대한 다양한 방법에 대해 자세히 소개해 드립니다.
v	
  
Topics We’ll Cover
•  Amazon EC2
•  Types of Scaling
•  Auto Scaling Introduction
•  Auto Scaling Terminology
•  Best Practices
•  Console Demo
v	
  
Basic unit of compute capacity
Range of CPU, memory & local disk options
Feature
 Details
Flexible
 Run windows or linux distributions
Scalable
 Wide range of instance types from micro to cluster compute
Machine Images
 Configurations can be saved as machine images (AMIs) from which new instances
can be created
Full control
 Full root or administrator rights
Secure
 Full firewall control via Security Groups
Monitoring
 Publishes metrics to Cloud Watch
Inexpensive
 On-demand, Reserved and Spot instance types
VM Import/
Export
Import and export VM images to transfer configurations in and out of EC2
Amazon Elastic Compute Cloud (EC2)
 Amazon
EC2
v	
  
Types of Scaling
•  Vertical Scaling
•  Changing instance size
•  Increasing EBS Capacity
•  Horizontal Scaling
•  Adding / removing instances
•  ELB
r3.8xlarge
c3.2xlarge
m3.medium
m3.medium m3.medium m3.medium
m3.medium m3.medium m3.medium
v	
  
“We’re gonna need a bigger box”
•  Different EC2 instance type
•  High memory instances
•  High CPU instances
•  High I/O instances
•  High storage instances
•  Can now leverage PIOPs
•  Easy to change instance sizes
•  Will hit an endpoint eventually
r3.8xlarge
c3.2xlarge
m3.medium
v	
  
“We’re gonna need a bigger box”
•  Different EC2 instance type
•  High memory instances
•  High CPU instances
•  High I/O instances
•  High storage instances
•  Can now leverage PIOPs
•  Easy to change instance sizes
•  Will hit an endpoint eventually
r3.8xlarge
c3.2xlarge
m3.medium
v	
  
Traditional IT Usage Patterns
On	
  and	
  Off	
   Fast	
  Growth	
  
Variable	
  peaks	
   Predictable	
  peaks	
  
v	
  
Traditional IT Usage Patterns
On	
  and	
  Off	
   Fast	
  Growth	
  
Variable	
  peaks	
   Predictable	
  peaks	
  
Poor
Service
WASTE
v	
  
Auto Scaling
•  Automatic resizing of compute clusters based on demand
•  Define minimum and maximum number of instances
•  Define when scaling out and in occurs
•  Use metrics collected in Amazon CloudWatch to drive scaling
•  Run Auto Scaling for On-Demand and Spot instance types
•  Its Free! Amazon	
  
CloudWatch	
  
Usage	
  
Metrics	
  
Scaling	
  
InstrucDons	
  
Auto	
  Scaling	
  Group	
  
Queue	
  
Metrics	
  
Auto	
  Scaling	
  
v	
  
Cloud IT Usage Patterns (Auto
Scaling)
On	
  and	
  Off	
   Fast	
  Growth	
  
Variable	
  peaks	
   Predictable	
  peaks	
  
v	
  
Terminology for Auto Scaling
•  Auto Scaling Group
•  Launch Configuration
•  Scaling Plan
•  Amazon CloudWatch Alarm
•  Amazon SNS Notification
•  Elastic Load Balancer
•  Instance Lifecycle
•  Instance Metadata / Userdata
v	
  
Auto Scaling and AWS
Auto	
  Scaling	
  Groups	
  
•  EC2	
  instances	
  are	
  categorized	
  
into	
  Auto	
  Scaling	
  groups.	
  
•  Create	
  Auto	
  Scaling	
  groups	
  by	
  
defining	
  the	
  minimum,	
  
maximum,	
  and,	
  opDonally,	
  
the	
  desired	
  number	
  of	
  
running	
  EC2	
  instances.	
  
Launch	
  Configura5on	
  
•  Auto	
  Scaling	
  groups	
  use	
  a	
  
launch	
  configura.on	
  to	
  launch	
  
EC2	
  instances.	
  	
  
•  Create	
  the	
  launch	
  
configuraDon	
  by	
  providing	
  
informaDon	
  about	
  the	
  image	
  
you	
  want	
  Auto	
  Scaling	
  to	
  use	
  
to	
  launch	
  EC2	
  instances	
  
Scaling	
  Plan	
  
•  A	
  scaling	
  plan	
  tells	
  Auto	
  
Scaling	
  when	
  and	
  how	
  to	
  
scale.	
  	
  
•  Create	
  a	
  scaling	
  plan	
  based	
  on	
  
the	
  occurrence	
  of	
  specified	
  
condiDons	
  (dynamic	
  scaling)	
  
or	
  create	
  a	
  plan	
  based	
  on	
  a	
  
specific	
  schedule.	
  
v	
  
Retrieving Resource Metrics
•  CloudWatch: A web service that enables you to monitor and
manage various metrics, and configure alarm actions based
on data from those metrics.
•  A CloudWatch alarm is an object that monitors a single
metric over a specific period.
•  A metric is a variable that you want to monitor. eg: CPU usage,
or incoming network traffic.
•  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	
  
v	
  
Planning your Auto Scaling Group
•  How long it takes to launch and configure a server
•  What metrics have the most relevance to your application's
performance
•  What existing resources (such as EC2 instances or AMIs) you
might want to use as part of your Auto Scaling group
•  How many Availability Zones you want to the Auto Scaling
group to span
•  The role you want Auto Scaling to play in your application.
v	
  
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.
ElasDc	
  Load	
  Balancing	
  
v	
  
Understanding Auto Scaling
Cooldowns
Auto Scaling group
alarm
Auto Scaling
New instance
EC2 instances
v	
  
Understanding Auto Scaling
Cooldowns
Default	
  
Cooldown	
  
in	
  effect?	
  
Launch	
  or	
  
terminate	
  
instance	
  
Scaling	
  acDon	
  
occurs	
  
Ignore	
  acDon	
  
No	
  
Yes	
  
v	
  
Auto Scaling Lifecycles
v	
  
Auto Scaling Lifecycle Hooks
v	
  
Introducing Bootstrapping
Bootstrapping: some examples
•  Install latest software
•  Copy data from S3
•  Register with DNS
•  Start services
•  Update packages
•  Reboot
•  Open port 80
•  Register with load balancer
•  Mount devices
v	
  
Bootstrapping tools
• Scripts on instance (Bash, Powershell)
• Config Management Tools (Chef, Puppet)
• Amazon OpsWorks
v	
  
EC2 Metadata and UserData
•  Every EC2 Instance has access to local instance metadata
and userdata service
•  Metadata: immutable information about the instance

Accessible from within the instance via HTTP at
•  http://169.254.169.254/latest/meta-data/
v	
  
EC2 Metadata and UserData
EC2 Metadata and UserData
Script(s) on instance may retrieve useful information about
the instance, such as:
•  Host name
•  AMI ID
•  Instance ID
•  Public/Private DNS
•  Availability Zone
v	
  
EC2 Metadata and UserData
EC2 Metadata and UserData
•  Pass up to 16KB of text to an instance on launch
•  Text can be parsed by script on instance and used to
configure the machine
v	
  
UserData and CloudInit
•  CloudInit executes UserData on first boot if UserData begins
with:
•  #! (Linux)
•  <script> (Windows; technically, EC2Config, not CloudInit, does
this)
v	
  
UserData and CloudInit
•  CloudInit executes UserData on first boot if UserData begins
with:
•  #! (Linux)
•  <script> (Windows; technically, EC2Config, not CloudInit, does
this)
•  CloudInit is installed on Amazon Linux, Ubuntu, and RHEL
AMIs
• EC2Config is installed on Windows Server AMIs
•  Both may be installed on other distributions via a package
repo or source
v	
  
UserData and CloudInit
•  UserData to install Apache and MySQL on boot, and attach an EIP:
#!/bin/bash
# Install Apache, PHP, and MySQL
yum install –y httpd mysql-server
# Attach an Elastic IP to this instance
ec2-associate-address 
23.34.45.56 
-i $(curl http://169.254.169.254/latest/meta-data/instance-id)
v	
  
Instance
request
User	
  
data	
  
v	
  
Instance
request
User	
  
data	
  
Meta-­‐data	
  
service	
  
v	
  
Instance
request
User	
  
data	
  
Instance	
  
Meta-­‐data	
  
service	
  
v	
  
33	

Amazon	
  Windows	
  EC2Config	
  Service	
  executes	
  user-­‐data	
  on	
  
launch:	
  
<script>dir > c:test.log</script>
<powershell>any command that you can run</powershell>
<powershell>
Read-S3Object -BucketName myS3Bucket
-Key myFolder/myFile.zip
-File c:destinationFile.zip
</powershell>
AWS	
  Powershell	
  Tools	
  (use	
  IAM	
  roles	
  as	
  before…)	
  	
  
v	
  
Why	
  do	
  this?	
  
AutomaDon	
  
Less	
  fingers,	
  less	
  mistakes	
  
Availability	
  
Drive	
  higher	
  
availability	
  with	
  self-­‐
healing	
  
Security	
  
Instances	
  locked	
  
down	
  by	
  default	
  
	
  
Flexible	
  
Shell,	
  Powershell,	
  
CloudFormaDon,C
hef,	
  Puppet,	
  
OpsWorks	
  	
  
Scale	
  
Manage	
  large	
  scale	
  
deployments	
  and	
  drive	
  
autoscaling	
  
Efficiency	
  
Audit	
  and	
  manage	
  
your	
  estate	
  with	
  less	
  
Dme	
  &	
  effort	
  
v	
  
Do	
  
Use	
  IAM	
  roles	
  
Go	
  keyless	
  if	
  you	
  can	
  
Strike	
  a	
  balance	
  between	
  
AMI	
  and	
  dynamic	
  
bootstrapping	
  
Some Do’s and Don’ts
v	
  
Do	
   Don’t	
  
Use	
  IAM	
  roles	
  
Go	
  keyless	
  if	
  you	
  can	
  
Strike	
  a	
  balance	
  between	
  
AMI	
  and	
  dynamic	
  
bootstrapping	
  
Put	
  your	
  API	
  access	
  keys	
  
into	
  code	
  (and	
  then	
  publish	
  
to	
  GIT)	
  or	
  bake	
  into	
  AMIs	
  
(and	
  share)	
  
L	
  	
  
Some Do’s and Don’ts
v	
  
Autoscaling isn’t one size fits all
•  Choose the right metrics
•  CPU Usage
•  Queue Depth
•  Number of concurrent users
•  Scale too aggressively
•  Overprovisioning: increases costs
•  Bounciness: Add more than you need and have to partially scale back
shortly after scaling up, increasing costs.
•  Scale too timidly
•  Poor performance
•  Outages due to lack of capacity
•  Scale out early / Scale in slowly
v	
  
What’s new?
•  Attach / Detach Instances from Auto Scaling Groups
•  Place instances into Standby State to Troubleshoot
•  Hold instances in Pending state for installing software /
retrieve logs
•  Create an Auto Scaling Group / Launch Configuration based
on a running instance
온라인 자습 및 실습
다양한 온라인 강의 자
료 및 실습을 통해 AWS
에 대한 기초적인 사용
법 및 활용 방법을 익히
실 수 있습니다.
강의식 교육
AWS 전문 강사가 진행하는 강의를
통해 AWS 클라우드로 고가용성,
비용 효율성을 갖춘 안전한 애플리
케이션을 만드는 방법을 알아보세
요. 아키텍쳐 설계 및 구현에 대한
다양한 오프라인 강의가 개설되어
있습니다.
인증 시험을 통해 클라우
드에 대한 자신의 전문 지
식 및 경험을 공인받고 개
발 경력을 제시할 수 있습
니다.
AWS 공인 자격증
http://aws.amazon.com/ko/training
다양한 교육 프로그램
AWS 기초 웨비나 시리즈에 참여해 주셔서 감사합니다!
이번 웨비나가 여러분의 궁금증 해소에 도움이 되었길 바랍니다.
이후 이어질 설문 조사를 통해 오늘 웨비나에 대한 의견을 알려주세요.
aws-korea-marketing@amazon.com
http://twitter.com/AWSKorea
http://facebook.com/AmazonWebServices.ko
http://youtube.com/user/AWSKorea
http://slideshare.net/AWSKorea

오토스케일링 제대로 활용하기 (김일호) - AWS 웨비나 시리즈 2015

  • 1.
    심화 웨비나 시리즈| 7 번째 강연 2015년 7월 9일 목요일 | 오전 10시 http://aws.amazon.com/ko 오토스케일링 제대로 활용하기
  • 2.
  • 3.
    이번 웨비나 에서들으실 내용.. 오토스케일링(Autho-scaling)은 AWS 클라우드를 통해 확장성 높은 서비스와 아키텍쳐를 구성하는 가장 중요한 방식 중 하나입니다. 본 강연에서는 효과적인 클라우드 인프라 사용 패턴을 제공하기 위한 오토 스케일링에 대한 다양한 방법에 대해 자세히 소개해 드립니다.
  • 4.
    v   Topics We’llCover •  Amazon EC2 •  Types of Scaling •  Auto Scaling Introduction •  Auto Scaling Terminology •  Best Practices •  Console Demo
  • 5.
    v   Basic unitof compute capacity Range of CPU, memory & local disk options Feature Details Flexible Run windows or linux distributions Scalable Wide range of instance types from micro to cluster compute Machine Images Configurations can be saved as machine images (AMIs) from which new instances can be created Full control Full root or administrator rights Secure Full firewall control via Security Groups Monitoring Publishes metrics to Cloud Watch Inexpensive On-demand, Reserved and Spot instance types VM Import/ Export Import and export VM images to transfer configurations in and out of EC2 Amazon Elastic Compute Cloud (EC2) Amazon EC2
  • 6.
    v   Types ofScaling •  Vertical Scaling •  Changing instance size •  Increasing EBS Capacity •  Horizontal Scaling •  Adding / removing instances •  ELB r3.8xlarge c3.2xlarge m3.medium m3.medium m3.medium m3.medium m3.medium m3.medium m3.medium
  • 7.
    v   “We’re gonnaneed a bigger box” •  Different EC2 instance type •  High memory instances •  High CPU instances •  High I/O instances •  High storage instances •  Can now leverage PIOPs •  Easy to change instance sizes •  Will hit an endpoint eventually r3.8xlarge c3.2xlarge m3.medium
  • 8.
    v   “We’re gonnaneed a bigger box” •  Different EC2 instance type •  High memory instances •  High CPU instances •  High I/O instances •  High storage instances •  Can now leverage PIOPs •  Easy to change instance sizes •  Will hit an endpoint eventually r3.8xlarge c3.2xlarge m3.medium
  • 9.
    v   Traditional ITUsage Patterns On  and  Off   Fast  Growth   Variable  peaks   Predictable  peaks  
  • 10.
    v   Traditional ITUsage Patterns On  and  Off   Fast  Growth   Variable  peaks   Predictable  peaks   Poor Service WASTE
  • 11.
    v   Auto Scaling • Automatic resizing of compute clusters based on demand •  Define minimum and maximum number of instances •  Define when scaling out and in occurs •  Use metrics collected in Amazon CloudWatch to drive scaling •  Run Auto Scaling for On-Demand and Spot instance types •  Its Free! Amazon   CloudWatch   Usage   Metrics   Scaling   InstrucDons   Auto  Scaling  Group   Queue   Metrics   Auto  Scaling  
  • 12.
    v   Cloud ITUsage Patterns (Auto Scaling) On  and  Off   Fast  Growth   Variable  peaks   Predictable  peaks  
  • 13.
    v   Terminology forAuto Scaling •  Auto Scaling Group •  Launch Configuration •  Scaling Plan •  Amazon CloudWatch Alarm •  Amazon SNS Notification •  Elastic Load Balancer •  Instance Lifecycle •  Instance Metadata / Userdata
  • 14.
    v   Auto Scalingand AWS Auto  Scaling  Groups   •  EC2  instances  are  categorized   into  Auto  Scaling  groups.   •  Create  Auto  Scaling  groups  by   defining  the  minimum,   maximum,  and,  opDonally,   the  desired  number  of   running  EC2  instances.   Launch  Configura5on   •  Auto  Scaling  groups  use  a   launch  configura.on  to  launch   EC2  instances.     •  Create  the  launch   configuraDon  by  providing   informaDon  about  the  image   you  want  Auto  Scaling  to  use   to  launch  EC2  instances   Scaling  Plan   •  A  scaling  plan  tells  Auto   Scaling  when  and  how  to   scale.     •  Create  a  scaling  plan  based  on   the  occurrence  of  specified   condiDons  (dynamic  scaling)   or  create  a  plan  based  on  a   specific  schedule.  
  • 15.
    v   Retrieving ResourceMetrics •  CloudWatch: A web service that enables you to monitor and manage various metrics, and configure alarm actions based on data from those metrics. •  A CloudWatch alarm is an object that monitors a single metric over a specific period. •  A metric is a variable that you want to monitor. eg: CPU usage, or incoming network traffic. •  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  
  • 16.
    v   Planning yourAuto Scaling Group •  How long it takes to launch and configure a server •  What metrics have the most relevance to your application's performance •  What existing resources (such as EC2 instances or AMIs) you might want to use as part of your Auto Scaling group •  How many Availability Zones you want to the Auto Scaling group to span •  The role you want Auto Scaling to play in your application.
  • 17.
    v   Load Balanceyour 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. ElasDc  Load  Balancing  
  • 18.
    v   Understanding AutoScaling Cooldowns Auto Scaling group alarm Auto Scaling New instance EC2 instances
  • 19.
    v   Understanding AutoScaling Cooldowns Default   Cooldown   in  effect?   Launch  or   terminate   instance   Scaling  acDon   occurs   Ignore  acDon   No   Yes  
  • 20.
  • 21.
    v   Auto ScalingLifecycle Hooks
  • 22.
    v   Introducing Bootstrapping Bootstrapping:some examples •  Install latest software •  Copy data from S3 •  Register with DNS •  Start services •  Update packages •  Reboot •  Open port 80 •  Register with load balancer •  Mount devices
  • 23.
    v   Bootstrapping tools • Scriptson instance (Bash, Powershell) • Config Management Tools (Chef, Puppet) • Amazon OpsWorks
  • 24.
    v   EC2 Metadataand UserData •  Every EC2 Instance has access to local instance metadata and userdata service •  Metadata: immutable information about the instance Accessible from within the instance via HTTP at •  http://169.254.169.254/latest/meta-data/
  • 25.
    v   EC2 Metadataand UserData EC2 Metadata and UserData Script(s) on instance may retrieve useful information about the instance, such as: •  Host name •  AMI ID •  Instance ID •  Public/Private DNS •  Availability Zone
  • 26.
    v   EC2 Metadataand UserData EC2 Metadata and UserData •  Pass up to 16KB of text to an instance on launch •  Text can be parsed by script on instance and used to configure the machine
  • 27.
    v   UserData andCloudInit •  CloudInit executes UserData on first boot if UserData begins with: •  #! (Linux) •  <script> (Windows; technically, EC2Config, not CloudInit, does this)
  • 28.
    v   UserData andCloudInit •  CloudInit executes UserData on first boot if UserData begins with: •  #! (Linux) •  <script> (Windows; technically, EC2Config, not CloudInit, does this) •  CloudInit is installed on Amazon Linux, Ubuntu, and RHEL AMIs • EC2Config is installed on Windows Server AMIs •  Both may be installed on other distributions via a package repo or source
  • 29.
    v   UserData andCloudInit •  UserData to install Apache and MySQL on boot, and attach an EIP: #!/bin/bash # Install Apache, PHP, and MySQL yum install –y httpd mysql-server # Attach an Elastic IP to this instance ec2-associate-address 23.34.45.56 -i $(curl http://169.254.169.254/latest/meta-data/instance-id)
  • 30.
  • 31.
    v   Instance request User   data   Meta-­‐data   service  
  • 32.
    v   Instance request User   data   Instance   Meta-­‐data   service  
  • 33.
    v   33 Amazon  Windows  EC2Config  Service  executes  user-­‐data  on   launch:   <script>dir > c:test.log</script> <powershell>any command that you can run</powershell> <powershell> Read-S3Object -BucketName myS3Bucket -Key myFolder/myFile.zip -File c:destinationFile.zip </powershell> AWS  Powershell  Tools  (use  IAM  roles  as  before…)    
  • 34.
    v   Why  do  this?   AutomaDon   Less  fingers,  less  mistakes   Availability   Drive  higher   availability  with  self-­‐ healing   Security   Instances  locked   down  by  default     Flexible   Shell,  Powershell,   CloudFormaDon,C hef,  Puppet,   OpsWorks     Scale   Manage  large  scale   deployments  and  drive   autoscaling   Efficiency   Audit  and  manage   your  estate  with  less   Dme  &  effort  
  • 35.
    v   Do   Use  IAM  roles   Go  keyless  if  you  can   Strike  a  balance  between   AMI  and  dynamic   bootstrapping   Some Do’s and Don’ts
  • 36.
    v   Do  Don’t   Use  IAM  roles   Go  keyless  if  you  can   Strike  a  balance  between   AMI  and  dynamic   bootstrapping   Put  your  API  access  keys   into  code  (and  then  publish   to  GIT)  or  bake  into  AMIs   (and  share)   L     Some Do’s and Don’ts
  • 37.
    v   Autoscaling isn’tone size fits all •  Choose the right metrics •  CPU Usage •  Queue Depth •  Number of concurrent users •  Scale too aggressively •  Overprovisioning: increases costs •  Bounciness: Add more than you need and have to partially scale back shortly after scaling up, increasing costs. •  Scale too timidly •  Poor performance •  Outages due to lack of capacity •  Scale out early / Scale in slowly
  • 38.
    v   What’s new? • Attach / Detach Instances from Auto Scaling Groups •  Place instances into Standby State to Troubleshoot •  Hold instances in Pending state for installing software / retrieve logs •  Create an Auto Scaling Group / Launch Configuration based on a running instance
  • 39.
    온라인 자습 및실습 다양한 온라인 강의 자 료 및 실습을 통해 AWS 에 대한 기초적인 사용 법 및 활용 방법을 익히 실 수 있습니다. 강의식 교육 AWS 전문 강사가 진행하는 강의를 통해 AWS 클라우드로 고가용성, 비용 효율성을 갖춘 안전한 애플리 케이션을 만드는 방법을 알아보세 요. 아키텍쳐 설계 및 구현에 대한 다양한 오프라인 강의가 개설되어 있습니다. 인증 시험을 통해 클라우 드에 대한 자신의 전문 지 식 및 경험을 공인받고 개 발 경력을 제시할 수 있습 니다. AWS 공인 자격증 http://aws.amazon.com/ko/training 다양한 교육 프로그램
  • 40.
    AWS 기초 웨비나시리즈에 참여해 주셔서 감사합니다! 이번 웨비나가 여러분의 궁금증 해소에 도움이 되었길 바랍니다. 이후 이어질 설문 조사를 통해 오늘 웨비나에 대한 의견을 알려주세요. aws-korea-marketing@amazon.com http://twitter.com/AWSKorea http://facebook.com/AmazonWebServices.ko http://youtube.com/user/AWSKorea http://slideshare.net/AWSKorea