[mar aws 201] auto scaling demo
TRANSCRIPT
AMAZON WEB SERVICES CONFIDENTIAL. THIS DOCUMENT MAY NOT BE DISCLOSED WITHOUT AMAZON WEB SERVICES’ PRIOR WRITTEN CONSENT. This document is for discussion purposes only. Neither party will have any obligaNon or liability with respect to the maOers described in this document (other than confidenNality obligaNons), unless and unNl a definiNve wriOen agreement addressing such maOers is executed by each party, and neither party will have any liability for any failure or refusal to enter into a definiNve agreement for any reason.
Auto Scaling Demo
Ilho Kim Solutions Architect
March 2013
AMAZON WEB SERVICES CONFIDENTIAL. THIS DOCUMENT MAY NOT BE DISCLOSED WITHOUT AMAZON WEB SERVICES’ PRIOR WRITTEN CONSENT. This document is for discussion purposes only. Neither party will have any obligaNon or liability with respect to the maOers described in this document (other than confidenNality obligaNons), unless and unNl a definiNve wriOen agreement addressing such maOers is executed by each party, and neither party will have any liability for any failure or refusal to enter into a definiNve agreement for any reason.
This document is intended solely for discussion purposes. Amazon Web Services has provided answers based on its current knowledge, but these answers may change due to a variety of factors, including changes in aOendees’ requirements, the capabiliNes of the third party selected to assist with implementaNon, and changes to Amazon Web Services offerings. Any agreement between Amazon Web Services and aOendees regarding the proposed soluNon will be documented in a separate definiNve agreement, not this proposal.
General Disclaimer
AMAZON WEB SERVICES CONFIDENTIAL. THIS DOCUMENT MAY NOT BE DISCLOSED WITHOUT AMAZON WEB SERVICES’ PRIOR WRITTEN CONSENT. This document is for discussion purposes only. Neither party will have any obligaNon or liability with respect to the maOers described in this document (other than confidenNality obligaNons), unless and unNl a definiNve wriOen agreement addressing such maOers is executed by each party, and neither party will have any liability for any failure or refusal to enter into a definiNve agreement for any reason.
• You have registered AWS. • You know how to login AWS console • You know how to connect w/ ssh to instances • You know auth. Key / secret Key • VPC(Virtual Private Cloud) configured
– Two private subnets(each one in each AZ) – IGW – ELB (internet-‐facing)
• AWS CLI installed (EC2, Auto Scaling) – setup environments/java/path/credenNals
Assuming
AMAZON WEB SERVICES CONFIDENTIAL. THIS DOCUMENT MAY NOT BE DISCLOSED WITHOUT AMAZON WEB SERVICES’ PRIOR WRITTEN CONSENT. This document is for discussion purposes only. Neither party will have any obligaNon or liability with respect to the maOers described in this document (other than confidenNality obligaNons), unless and unNl a definiNve wriOen agreement addressing such maOers is executed by each party, and neither party will have any liability for any failure or refusal to enter into a definiNve agreement for any reason.
Demo Architecture
Availability Zone #1
Auto Scaling group : Web App Tier
Apache
PHP Mod
Apache
PHP Mod
Elas@c Load Balancer
Amazon Route 53 (DNS)
Amazon CloudWatch (Monitoring)
Availability Zone #2
Auto Scaling group : Web App Tier
Apache
PHP Mod
Apache
PHP Mod
Region
Internet GateWay
Private Subnet Private Subnet
AMAZON WEB SERVICES CONFIDENTIAL. THIS DOCUMENT MAY NOT BE DISCLOSED WITHOUT AMAZON WEB SERVICES’ PRIOR WRITTEN CONSENT. This document is for discussion purposes only. Neither party will have any obligaNon or liability with respect to the maOers described in this document (other than confidenNality obligaNons), unless and unNl a definiNve wriOen agreement addressing such maOers is executed by each party, and neither party will have any liability for any failure or refusal to enter into a definiNve agreement for any reason.
• Web/Was in private subnets in VPC – 10.0.0.0/16
• 10.0.1.0/24, 10.0.2.0/24
• ELB – Internet-‐facing (not internal) – Set traffic into both subnets(= both AZs)
• IGW aOached • Using hOpd, php and index.php pre-‐installed AMI • RouNng Tables, SG configured for web service(look at console)
Architecture details
AMAZON WEB SERVICES CONFIDENTIAL. THIS DOCUMENT MAY NOT BE DISCLOSED WITHOUT AMAZON WEB SERVICES’ PRIOR WRITTEN CONSENT. This document is for discussion purposes only. Neither party will have any obligaNon or liability with respect to the maOers described in this document (other than confidenNality obligaNons), unless and unNl a definiNve wriOen agreement addressing such maOers is executed by each party, and neither party will have any liability for any failure or refusal to enter into a definiNve agreement for any reason.
• Instance type : t1.micro • AMI : ami-‐668a150f
– HOpd, php installed – Index.php (dump instance informaNon)
Architecture details
<?php $output = shell_exec('curl 169.254.169.254/latest/dynamic/instance-‐idenNty/document/'); echo "<pre>$output</pre>"; ?>
AMAZON WEB SERVICES CONFIDENTIAL. THIS DOCUMENT MAY NOT BE DISCLOSED WITHOUT AMAZON WEB SERVICES’ PRIOR WRITTEN CONSENT. This document is for discussion purposes only. Neither party will have any obligaNon or liability with respect to the maOers described in this document (other than confidenNality obligaNons), unless and unNl a definiNve wriOen agreement addressing such maOers is executed by each party, and neither party will have any liability for any failure or refusal to enter into a definiNve agreement for any reason.
• Auto Scaling basic Commands • CMD -‐-‐help shows opNons
Auto Scaling CLI
AMAZON WEB SERVICES CONFIDENTIAL. THIS DOCUMENT MAY NOT BE DISCLOSED WITHOUT AMAZON WEB SERVICES’ PRIOR WRITTEN CONSENT. This document is for discussion purposes only. Neither party will have any obligaNon or liability with respect to the maOers described in this document (other than confidenNality obligaNons), unless and unNl a definiNve wriOen agreement addressing such maOers is executed by each party, and neither party will have any liability for any failure or refusal to enter into a definiNve agreement for any reason.
• as-‐create-‐launch-‐config – Image-‐id – Instance Type – Key (do not add “.pem”) – Group (VPC Security Group, not EC2) – Launch-‐config (the name of configuraNon)
CreaNng Launch ConfiguraNon
$ as-‐create-‐launch-‐config -‐-‐image-‐id ami-‐668a150f -‐-‐instance-‐type t1.micro -‐-‐key test_web -‐-‐group sg-‐ae9665c1 -‐-‐launch-‐config web-‐as-‐config
Not name, SG Group ID!
AMAZON WEB SERVICES CONFIDENTIAL. THIS DOCUMENT MAY NOT BE DISCLOSED WITHOUT AMAZON WEB SERVICES’ PRIOR WRITTEN CONSENT. This document is for discussion purposes only. Neither party will have any obligaNon or liability with respect to the maOers described in this document (other than confidenNality obligaNons), unless and unNl a definiNve wriOen agreement addressing such maOers is executed by each party, and neither party will have any liability for any failure or refusal to enter into a definiNve agreement for any reason.
• as-‐create-‐auto-‐scaling-‐group – Auto Scaling Group Name – Availability Zones = AZ,AZ… – Launch ConfiguraNon Name – Load Balancer Names – MaxSize – MinSize – vpc-‐zone-‐iden@fier (Not VPC ID, subnet IDs !) – region
Create Auto Scaling Group
$ as-‐create-‐auto-‐scaling-‐group web-‐as-‐group -‐-‐availability-‐zones us-‐east-‐1b,us-‐east-‐1c -‐-‐launch-‐configuraNon web-‐as-‐config -‐-‐load-‐balancers webloadbal-‐vpc -‐-‐max-‐size 6 -‐-‐min-‐size 2 -‐-‐vpc-‐zone-‐idenNfier 'subnet-‐5718c13a,subnet-‐7f18c112' -‐-‐region us-‐east-‐1
Press Enter = Auto Scaling start!
AMAZON WEB SERVICES CONFIDENTIAL. THIS DOCUMENT MAY NOT BE DISCLOSED WITHOUT AMAZON WEB SERVICES’ PRIOR WRITTEN CONSENT. This document is for discussion purposes only. Neither party will have any obligaNon or liability with respect to the maOers described in this document (other than confidenNality obligaNons), unless and unNl a definiNve wriOen agreement addressing such maOers is executed by each party, and neither party will have any liability for any failure or refusal to enter into a definiNve agreement for any reason.
• Now Auto Scaling starts! (-‐-‐min-‐size 2) • Go to browser and type ELB URL
– Ex. hOp://webloadbal-‐vpc-‐652639900.us-‐east-‐1.elb.amazonaws.com/
Check if AS is working
{ "instanceId" : "i-‐14b3a167", "billingProducts" : null, "version" : "2010-‐08-‐31", "imageId" : "ami-‐668a150f", "accountId" : ”12345678901", "instanceType" : "t1.micro", "kernelId" : "aki-‐88aa75e1", "ramdiskId" : null, "architecture" : "x86_64", "pendingTime" : "2013-‐03-‐10T10:45:03Z", "availabilityZone" : "us-‐east-‐1c", "devpayProductCodes" : null, "privateIp" : "10.0.2.73", "region" : "us-‐east-‐1" }
{ "instanceId" : "i-‐f2584581", "billingProducts" : null, "version" : "2010-‐08-‐31", "imageId" : "ami-‐668a150f", "accountId" : "806506827877", "instanceType" : "t1.micro", "kernelId" : "aki-‐88aa75e1", "ramdiskId" : null, "architecture" : "x86_64", "pendingTime" : "2013-‐03-‐10T11:08:18Z", "availabilityZone" : "us-‐east-‐1b", "devpayProductCodes" : null, "privateIp" : "10.0.1.87", "region" : "us-‐east-‐1" }
AMAZON WEB SERVICES CONFIDENTIAL. THIS DOCUMENT MAY NOT BE DISCLOSED WITHOUT AMAZON WEB SERVICES’ PRIOR WRITTEN CONSENT. This document is for discussion purposes only. Neither party will have any obligaNon or liability with respect to the maOers described in this document (other than confidenNality obligaNons), unless and unNl a definiNve wriOen agreement addressing such maOers is executed by each party, and neither party will have any liability for any failure or refusal to enter into a definiNve agreement for any reason.
Create Auto Scaling Policy
• Create Scale Up Policy
• Create Scale Down Policy
$ as-‐put-‐scaling-‐policy webScaleUpPolicy -‐-‐auto-‐scaling-‐group web-‐as-‐group -‐-‐adjustment=1 -‐-‐type ChangeInCapacity -‐-‐cooldown 180 ��
$ as-‐put-‐scaling-‐policy webScaleDownPolicy -‐-‐auto-‐scaling-‐group web-‐as-‐group "-‐-‐adjustment=-‐1" -‐-‐type ChangeInCapacity -‐-‐ cooldown 300
Need to be in quote!
Event Cooldown Event
AMAZON WEB SERVICES CONFIDENTIAL. THIS DOCUMENT MAY NOT BE DISCLOSED WITHOUT AMAZON WEB SERVICES’ PRIOR WRITTEN CONSENT. This document is for discussion purposes only. Neither party will have any obligaNon or liability with respect to the maOers described in this document (other than confidenNality obligaNons), unless and unNl a definiNve wriOen agreement addressing such maOers is executed by each party, and neither party will have any liability for any failure or refusal to enter into a definiNve agreement for any reason.
Create Auto Scaling Policy
• Go to CloudWatch !! • Create alarms for auto scaling by CPU UNlizaNon
More sensiNve
web
web
web
web
AMAZON WEB SERVICES CONFIDENTIAL. THIS DOCUMENT MAY NOT BE DISCLOSED WITHOUT AMAZON WEB SERVICES’ PRIOR WRITTEN CONSENT. This document is for discussion purposes only. Neither party will have any obligaNon or liability with respect to the maOers described in this document (other than confidenNality obligaNons), unless and unNl a definiNve wriOen agreement addressing such maOers is executed by each party, and neither party will have any liability for any failure or refusal to enter into a definiNve agreement for any reason.
Create Auto Scaling Policy
• CPU UNlizaNon >= 40% à Spin up a new Instance
• CPU UNlizaNon <= 10% à Remove the Instance web
web
web
web
AMAZON WEB SERVICES CONFIDENTIAL. THIS DOCUMENT MAY NOT BE DISCLOSED WITHOUT AMAZON WEB SERVICES’ PRIOR WRITTEN CONSENT. This document is for discussion purposes only. Neither party will have any obligaNon or liability with respect to the maOers described in this document (other than confidenNality obligaNons), unless and unNl a definiNve wriOen agreement addressing such maOers is executed by each party, and neither party will have any liability for any failure or refusal to enter into a definiNve agreement for any reason.
• HOp Load GeneraNng – ApacheBench
• $ ab –n “the # of request” –c “the # of concurrency” URL
Test Auto Scaling
$ ab -‐n 1000000 -‐c 1000 \ hOp://webloadbal-‐vpc-‐652639900.us-‐east-‐1.elb.amazonaws.com/
web web web web web web
AMAZON WEB SERVICES CONFIDENTIAL. THIS DOCUMENT MAY NOT BE DISCLOSED WITHOUT AMAZON WEB SERVICES’ PRIOR WRITTEN CONSENT. This document is for discussion purposes only. Neither party will have any obligaNon or liability with respect to the maOers described in this document (other than confidenNality obligaNons), unless and unNl a definiNve wriOen agreement addressing such maOers is executed by each party, and neither party will have any liability for any failure or refusal to enter into a definiNve agreement for any reason.
1. as-‐describe-‐auto-‐scaling-‐groups web-‐as-‐group –headers 2. as-‐update-‐auto-‐scaling-‐group web-‐as-‐group -‐-‐min-‐size 0 -‐-‐
max-‐size 0 3. as-‐describe-‐auto-‐scaling-‐groups web-‐as-‐group –headers 4. as-‐delete-‐auto-‐scaling-‐group web-‐as-‐group 5. as-‐delete-‐launch-‐config web-‐as-‐config 6. as-‐describe-‐auto-‐scaling-‐groups –headers
Note: All policies associated with dele1ng AS will be removed. Op1onal. 7. Delete Cloudwatch 8. Delete Load Balancer
Delete Auto Scaling
AMAZON WEB SERVICES CONFIDENTIAL. THIS DOCUMENT MAY NOT BE DISCLOSED WITHOUT AMAZON WEB SERVICES’ PRIOR WRITTEN CONSENT. This document is for discussion purposes only. Neither party will have any obligaNon or liability with respect to the maOers described in this document (other than confidenNality obligaNons), unless and unNl a definiNve wriOen agreement addressing such maOers is executed by each party, and neither party will have any liability for any failure or refusal to enter into a definiNve agreement for any reason.
Thank You! Ilho Kim
aws.amazon.com