Amazon documentation states that

Auto Scaling allows you to automatically scale your Amazon EC2 capacity up or down according to conditions you define.

Simply put, it can start and stop ec2 instances based on a condition you define. This is especially important in an environment where you pay more for more capacity. Thus if a website has a defined traffic pattern such as traffic peaks every afternoon and goes down in the night, you can have autoscaling start more web servers in the afternoon and shut down unnecessary ones in the night. Isn’t that amazing?


You need to be using an elastic load balancer to configure auto scaling. Configuring autoscaling consists of three steps:
1) Create launch configuration
2) Create auto scaling group
3) Create auto scaling trigger

Create launch configuration
Launch configuration provides information about the instance to be launched. You can see that an AMI, instance type, availability zone and security groups are specified when a luanch configuration is created.

as-create-launch-config web --image-id ami-656583ff --instance-type m1.small --group ssh,web --key my-keypair

Create autoscaling group
A launch configuration is attached with an autoscaling group. The group consists of pool of instances. You can specify minimum and maximum size of the pool

as-create-auto-scaling-group myasgroup --launch-configuration web --availability-zones us-east-1a --min-size 4 --max-size 10 --cooldown 120 --load-balancers myloadbalancer

Create autoscaling trigger
The trigger defines the conditions to start or stop ec2 instances. For example:

as-create-or-update-trigger my-latency-trigger --auto-scaling-group myasgroup --dimensions "LoadBalancerName=myloadbalancer" --measure Latency --period 60 --statistic Average --lower-threshold 0.25 --upper-threshold 0.75 --breach-duration 300 --lower-breach-increment=-1 --upper-breach-increment 1 --namespace "AWS/ELB" --unit Seconds

will create a latency trigger with 0.25 as the lower threshold and 0.75 seconds as the upper threshold. If your website latency goes beyond 0.75 seconds, this trigger will be activated and hence an instance will be launched (as specified by upper breach increment). Besides latency you can use different dimensions monitored by cloudwatch such as request count, health host count and unhealthy host count.

That’s it! It’s that simple. More information about autoscaling can be read here.

Share and Enjoy:
  • Sphinn
  • Twitter
  • Digg
  • Reddit
  • del.icio.us
  • Facebook
  • LinkedIn
  • StumbleUpon