Auto Scaling AWS

624 views

Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Auto Scaling AWS

  1. 1. Auto-Scaling no AWS Thiago Rondon, thiago@b-datum.com Encontro Técnico b-datum.com Friday, November 29, 13
  2. 2. termostato “manter constante a temperatura de um determinado ambiente” Friday, November 29, 13
  3. 3. capacidade problemas desperdício tradicional desperdício necessidade tempo Friday, November 29, 13
  4. 4. ELB Friday, November 29, 13 round-robin Elastic Load Balacing sticky sessions *default disable múltiplas regiões saúde do EC2
  5. 5. CloudWatch métricas próprias alarmes console ou API Friday, November 29, 13
  6. 6. Amazon Machine Image EC2 & AMI Elastic Compute Cloud Friday, November 29, 13
  7. 7. aws.amazon.com/developertools Friday, November 29, 13
  8. 8. $  aws  configure X vim  secrets.txt AWSAccessKeyId=0000000 AWSSecretKey=222222+33333333 export  AWS_CREDENTIAL_FILE=secrets.txt Friday, November 29, 13
  9. 9. Friday, November 29, 13
  10. 10. #  as-­‐ as-­‐cmd                                                                              as-­‐describe-­‐auto-­‐scaling-­‐instances                      as-­‐enable-­‐metrics-­‐collection as-­‐create-­‐auto-­‐scaling-­‐group                                  as-­‐describe-­‐auto-­‐scaling-­‐notification-­‐types    as-­‐execute-­‐policy as-­‐create-­‐launch-­‐config                                            as-­‐describe-­‐launch-­‐configs                                      as-­‐put-­‐notification-­‐configuration as-­‐create-­‐or-­‐update-­‐tags                                          as-­‐describe-­‐metric-­‐collection-­‐types                    as-­‐put-­‐scaling-­‐policy as-­‐delete-­‐auto-­‐scaling-­‐group                                  as-­‐describe-­‐notification-­‐configurations            as-­‐put-­‐scheduled-­‐update-­‐group-­‐action as-­‐delete-­‐launch-­‐config                                            as-­‐describe-­‐policies                                                  as-­‐resume-­‐processes as-­‐delete-­‐notification-­‐configuration                  as-­‐describe-­‐process-­‐types                                        as-­‐set-­‐desired-­‐capacity as-­‐delete-­‐policy                                                          as-­‐describe-­‐scaling-­‐activities                              as-­‐set-­‐instance-­‐health as-­‐delete-­‐scheduled-­‐action                                      as-­‐describe-­‐scheduled-­‐actions                                as-­‐suspend-­‐processes as-­‐delete-­‐tags                                                              as-­‐describe-­‐tags                                                          as-­‐terminate-­‐instance-­‐in-­‐auto-­‐scaling-­‐ group as-­‐describe-­‐adjustment-­‐types                                  as-­‐describe-­‐termination-­‐policy-­‐types                  as-­‐update-­‐auto-­‐scaling-­‐group as-­‐describe-­‐auto-­‐scaling-­‐groups                            as-­‐disable-­‐metrics-­‐collection                                as-­‐version Friday, November 29, 13
  11. 11. #  as-­‐create-­‐launch-­‐config  -­‐-­‐image-­‐id  ami-­‐43e0c12a     -­‐-­‐instance-­‐type  t1.micro  -­‐-­‐key  "thiago-­‐teste"     -­‐-­‐group  "default"  -­‐-­‐launch-­‐config  bdatum-­‐config OK-­‐Created  launch  config Friday, November 29, 13
  12. 12. #  as-­‐describe-­‐scaling-­‐activities No  activities  found Friday, November 29, 13
  13. 13. #  as-­‐create-­‐auto-­‐scaling-­‐group  bdatum-­‐scaling     -­‐-­‐launch-­‐configuration  bdatum-­‐config     -­‐-­‐availability-­‐zones  us-­‐east-­‐1d  -­‐-­‐min-­‐size  2     -­‐-­‐max-­‐size  10  -­‐-­‐load-­‐balancers  bdatum-­‐elb     -­‐-­‐health-­‐check-­‐type  ELB  -­‐-­‐grace-­‐period  300 OK-­‐Created  AutoScalingGroup Friday, November 29, 13
  14. 14. #  as-­‐put-­‐scaling-­‐policy     -­‐-­‐auto-­‐scaling-­‐group  bdatum-­‐scaling     -­‐-­‐name  scale-­‐up  -­‐-­‐adjustment  1     -­‐-­‐type  ChangeInCapacity  -­‐-­‐cooldown  300 arn:aws:autoscaling:us-­‐ east-­‐1:838846897022:scalingPolicy:c1016b4a-­‐8e2d-­‐43b5-­‐aa0c-­‐ fdc701ffd362:autoScalingGroupName/bdatum-­‐scaling:policyName/scale-­‐up Friday, November 29, 13
  15. 15. #  as-­‐put-­‐scaling-­‐policy     -­‐-­‐auto-­‐scaling-­‐group  bdatum-­‐scaling     -­‐-­‐name  scale-­‐dn  "-­‐-­‐adjustment=-­‐1"     -­‐-­‐type  ChangeInCapacity  -­‐-­‐cooldown  300 arn:aws:autoscaling:us-­‐east-­‐1:838846897022:scalingPolicy:4b514a9a-­‐ e89c-­‐4a65-­‐a288-­‐98ad7accbdec:autoScalingGroupName/bdatum-­‐scaling:policyName/ scale-­‐dn Friday, November 29, 13
  16. 16. #  mon-­‐put-­‐metric-­‐alarm  -­‐-­‐alarm-­‐name  sample-­‐scale-­‐up     -­‐-­‐alarm-­‐description  "Scale  up  at  80%  load"     -­‐-­‐metric-­‐name  CPUUtilization  -­‐-­‐namespace  AWS/EC2     -­‐-­‐statistic  Average  -­‐-­‐period  60  -­‐-­‐threshold  80     -­‐-­‐comparison-­‐operator  GreaterThanThreshold     -­‐-­‐dimensions  InstanceId=i-­‐37b12752  -­‐-­‐evaluation-­‐periods  3     -­‐-­‐unit  Percent  -­‐-­‐alarm-­‐actions OK-­‐Created  Alarm Friday, November 29, 13
  17. 17. #  mon-­‐put-­‐metric-­‐alarm  -­‐-­‐alarm-­‐name  sample-­‐scale-­‐dn     -­‐-­‐alarm-­‐description  "Scale  down  at  20%  load"     -­‐-­‐metric-­‐name  CPUUtilization  -­‐-­‐namespace  AWS/EC2     -­‐-­‐statistic  Average  -­‐-­‐period  60  -­‐-­‐threshold  20     -­‐-­‐comparison-­‐operator  LessThanThreshold     -­‐-­‐dimensions  InstanceId=i-­‐37b12752  -­‐-­‐evaluation-­‐periods  3     -­‐-­‐unit  Percent  -­‐-­‐alarm-­‐actions OK-­‐Created  Alarm Friday, November 29, 13
  18. 18. #  as-­‐describe-­‐scaling-­‐activities ACTIVITY    1a823de6-­‐e5a8-­‐4a6c-­‐b8a2-­‐1abf4eb03f97    2013-­‐11-­‐25T18:08:28Z     bdatum-­‐scaling    Failed    Cannot  find  Load  Balancer  bdatum-­‐elb.  Validating   load  balancer  configuration  failed. Friday, November 29, 13
  19. 19. Friday, November 29, 13
  20. 20. #  as-­‐describe-­‐scaling-­‐activities ACTIVITY    949ac330-­‐17d3-­‐4ec5-­‐b98b-­‐810faf4b6067                                                 bdatum-­‐scaling    PreInService ACTIVITY    ff225cbe-­‐38e8-­‐43f7-­‐bb4a-­‐d2a350472776    2013-­‐11-­‐25T18:17:02Z     bdatum-­‐scaling    Successful Friday, November 29, 13
  21. 21. Friday, November 29, 13
  22. 22. #  shutdown #  siege  -­‐c25  -­‐t10M  host Friday, November 29, 13
  23. 23. Friday, November 29, 13
  24. 24. Friday, November 29, 13
  25. 25. #  as-­‐describe-­‐auto-­‐scaling-­‐groups  bdatum-­‐scaling AUTO-­‐SCALING-­‐GROUP    bdatum-­‐scaling    bdatum-­‐config    us-­‐east-­‐1d    bdatum-­‐elb     2    10    2    Default INSTANCE    i-­‐2cba484a    us-­‐east-­‐1d    InService    Healthy    bdatum-­‐config INSTANCE    i-­‐2934164c    us-­‐east-­‐1d    InService    Healthy    bdatum-­‐config #  as-­‐delete-­‐auto-­‐scaling-­‐group  bdatum-­‐scaling  -­‐-­‐force-­‐delete        Are  you  sure  you  want  to  delete  this  AutoScalingGroup?  [Ny]y OK-­‐Deleted  AutoScalingGroup Friday, November 29, 13
  26. 26. #  as-­‐describe-­‐launch-­‐configs LAUNCH-­‐CONFIG    bdatum-­‐config    ami-­‐43e0c12a    t1.micro #  as-­‐delete-­‐launch-­‐config  bdatum-­‐config        Are  you  sure  you  want  to  delete  this  launch  configuration?  [Ny]y OK-­‐Deleted  launch  configuration Friday, November 29, 13
  27. 27. Disclaimer AWS cobra por hora. Friday, November 29, 13
  28. 28. Disclaimer Faça corretamente a desinstalação ! as-delete-auto-scaling-group <group> --force-delete as-delete-launch-config <group> Friday, November 29, 13
  29. 29. Disclaimer • • • • • Friday, November 29, 13 Neste exemplo a regra define uma condição particular de no mínimo 2 minutos. CloudWatch é um conjunto de coleções de dados que monitora as estatisticas como por exemplo a utilização de CPU. É um conjunto de protocolos, e em geral leva cerca de 60 segundos para agregar todas as informações. Autoscaling também leva outros 60 segundos. Então temos o tempo de boot do servidor. Um servidor grande e complexo pode levar alguns minutos para iniciar. Finalmente, o load balancer precisa monitorar esse servidor por algum tempo antes que ele se sinta confortável e seguro para direcionar os requests para a nova instancia.

×