40
심화 웨비나 시리즈 | 7 번째 강연 201579일 목요일 | 오전 10http://aws.amazon.com/ko 오토스케일링 제대로 활용하기

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

Embed Size (px)

Citation preview

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

심화 웨비나 시리즈 | 7 번째 강연 2015년 7월 9일 목요일 | 오전 10시

http://aws.amazon.com/ko

오토스케일링 제대로 활용하기

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

김일호, Solutions Architect

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

이번 웨비나 에서 들으실 내용..

오토스케일링(Autho-scaling)은 AWS 클라우드를 통해 확장성 높은 서비스와 아키텍쳐를 구성하는 가장 중요한 방식 중 하나입니다. 본 강연에서는 효과적인 클라우드 인프라 사용 패턴을 제공하기 위한 오토 스케일링에 대한 다양한 방법에 대해 자세히 소개해 드립니다.

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

v  

Topics We’ll Cover • Amazon EC2 • Types of Scaling • Auto Scaling Introduction • Auto Scaling Terminology • Best Practices • Console Demo

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

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

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

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

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

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

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

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

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

v  

Traditional IT Usage Patterns

On  and  Off   Fast  Growth  

Variable  peaks   Predictable  peaks  

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

v  

Traditional IT Usage Patterns

On  and  Off   Fast  Growth  

Variable  peaks   Predictable  peaks  

Poor Service

WASTE

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

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  

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

v  

Cloud IT Usage Patterns (Auto Scaling)

On  and  Off   Fast  Growth  

Variable  peaks   Predictable  peaks  

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

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

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

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.  

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

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  

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

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.

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

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  

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

v  

Understanding Auto Scaling Cooldowns

Auto Scaling group

alarm

Auto Scaling

New instance

EC2 instances

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

v  

Understanding Auto Scaling Cooldowns

Default  Cooldown  in  effect?  

Launch  or  terminate  instance  

Scaling  acDon  occurs  

Ignore  acDon  

No  

Yes  

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

v  

Auto Scaling Lifecycles

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

v  

Auto Scaling Lifecycle Hooks

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

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

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

v  

Bootstrapping tools

• Scripts on instance (Bash, Powershell) • Config Management Tools (Chef, Puppet) • Amazon OpsWorks

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

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/

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

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

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

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

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

v  

UserData and CloudInit • CloudInit executes UserData on first boot if UserData begins with:

•  #! (Linux) •  <script> (Windows; technically, EC2Config, not CloudInit, does

this)

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

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

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

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)

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

v  

Instance request

User  data  

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

v  

Instance request

User  data  

Meta-­‐data  service  

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

v  

Instance request

User  data  

Instance  

Meta-­‐data  service  

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

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…)    

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

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  

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

v  

Do  

Use  IAM  roles  

Go  keyless  if  you  can  

Strike  a  balance  between  AMI  and  dynamic  bootstrapping  

Some Do’s and Don’ts

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

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

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

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

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

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

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

온라인 자습 및 실습

다양한 온라인 강의 자료 및 실습을 통해 AWS에 대한 기초적인 사용법 및 활용 방법을 익히

실 수 있습니다.

강의식 교육

AWS 전문 강사가 진행하는 강의를 통해 AWS 클라우드로 고가용성,

비용 효율성을 갖춘 안전한 애플리케이션을 만드는 방법을 알아보세요. 아키텍쳐 설계 및 구현에 대한 다양한 오프라인 강의가 개설되어

있습니다.

인증 시험을 통해 클라우드에 대한 자신의 전문 지식 및 경험을 공인받고 개발 경력을 제시할 수 있습

니다.

AWS 공인 자격증

http://aws.amazon.com/ko/training

다양한 교육 프로그램

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

AWS 기초 웨비나 시리즈에 참여해 주셔서 감사합니다! 이번 웨비나가 여러분의 궁금증 해소에 도움이 되었길 바랍니다. 이후 이어질 설문 조사를 통해 오늘 웨비나에 대한 의견을 알려주세요. [email protected] http://twitter.com/AWSKorea http://facebook.com/AmazonWebServices.ko http://youtube.com/user/AWSKorea http://slideshare.net/AWSKorea