Auto scaling using cloud formation according to Request count

amazon-cloudwatch, amazon-ec2, amazon-web-services, aws-cloudformation

Solution

What you want to do is use the average for the load balancer. You can have different types of metrics. Sum, Average, Minimum, Maximum and Sample. If you choose Average it will give you an average for all the instances under the loadbalancer. So it will only trigger a new instance launch when all the servers in your group are at 1500 requests per minute.

Quick description of the type:

- Average - Average for the load balancer

- Sum - The total number of request (example: 3000)

- Maximum - The max number of requests any server has (because it might not be balanced exactly)

- Minimum - The min number of requests any server has (because it might not be balanced exactly)

- Sample - The number of servers used to calculate the average (essentially how many servers are on the load balancer)

You can create you're own custom metrics as well but you'll need to create an application that tells amazon what the values are. Using the cloud watch api you can easily create your own. Take a look here http://docs.amazonwebservices.com/AmazonCloudWatch/latest/DeveloperGuide/Welcome.html?r=1540

Problem

We are using cloud formation for auto scaling according based upon the load balancer RequestCount metric. Currently we scale up an instance if the request is increased to 1500 for 1 minute (each instance can handle 1500 request per minute). The problem is, since the autoscaling group continually checks the RequestCount and adds a new instance if the request count is greater than 1500 for 1 min. But it is not required as I now have 2 instances which can handle 3000 req. per minute. Is there any facility to make matrices custom? i.e. if new instance is added then the scale up policy will change to 3000 req. Example scenario: - Initially there is 1 ELB, 1 tomcat instance attached to ELB(can handle 1500 req. per min). - 1 cloud watch with action of scale up ploicy if the req. count on ELB is increased to 1500 for min. - Currently request load on ELB is 1500 for 1 min. now req. load is increased to 1700 for min. so it will attach a new tomcat instance on ELB. So i have 2 instance which can handle 3000 req. for min. - But now what problem is cloud watch still check the req. count on ELB and if req. load is 1700 for min. it will add one new tomcat instance which is not required. How can i over come from this problem?

Original source