Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Beanstalk Auto-scaling Scaling Triggers with HealthyHostCount or UnhealthyHost count

I have Elastic Beanstalk Environment , I need to setup autoscaling policy like if Elastic Loadbalancer has Unhealthy instance it will bring up new instance The Policy I used right now is below

My configuration

like image 284
abaid778 Avatar asked Mar 03 '15 12:03

abaid778


People also ask

Which AWS service triggers scale in and scale out in Auto Scaling?

The Auto Scaling group in your Elastic Beanstalk environment uses two Amazon CloudWatch alarms to trigger scaling operations. The default triggers scale when the average outbound network traffic from each instance is higher than 6 MB or lower than 2 MB over a period of five minutes.

Does Elastic Beanstalk automatically scale?

Your AWS Elastic Beanstalk environment includes an Auto Scaling group that manages the Amazon EC2 instances in your environment. In a single-instance environment, the Auto Scaling group ensures that there is always one instance running.

What is desired count in Auto Scaling?

Desired capacity simply means the number of instances that will come up / fired up when you launch the autoscaling. That means if desired capacity = 4, then 4 instances will keep on running until and unless any scale up or scale down event triggers.


3 Answers

The scaling triggers in EB console > Configuration > Capacity are a bit limited in the sense there is no option for <= and >=. To get full control of the triggers, go to AWS Console > EC2 > Auto Scaling Groups.

There select your Beanstalk app's Auto Scaling group (If you can't recognize your beanstalk app's Auto Scaling group then here is a tip: By default, the auto scaling group will be named in this fashion awseb-e-<Environment ID>-stack-AWSEBAutoScalingLaunchConfiguration-XXXXXXXXXXX. You can find our your beanstalk app's Environment ID from the app's dashboard)

On selection of the Auto Scaling group of your app, select Scaling Policies at the bottom. There you can read, in plain english, your triggers for upscaling and downscaling.

You will notice 2 policies of the form awseb-e-<Environment ID>-stack-AWSEBAutoScalingScaleDownPolicy-YYYYYYYYYY and awseb-e-<Environment ID>-stack-AWSEBAutoScalingScaleUpPolicy-ZZZZZZZZZZ. For each policy, there will be a CloudWatch alarm, of the form awseb-e-<Environment ID>-stack-AWSEBCloudwatchAlarm***-AAAAAAAAAA, asscociated as trigger.

Then if you want to fine tune the trigger, go to AWS CloudWatch > Alarms and select your alarm. Here you will get a lot more options to edit your triggers. You can select thresholds such as <= and >= and add SNS topics etc. A lot more options.

Edit, and Update Alarm and go back to your Auto Scaling Group's Scaling policies. You will see the new updates there, again in plain English and very easy to follow and understand.

like image 198
Madhu Babu Adiki Avatar answered Nov 04 '22 02:11

Madhu Babu Adiki


Change that first option "HealthyInstanceCount" to UnHealthyInstanceCount and if there's 1 or more unhealthy, add +1 instance. If UnHealthyInstanceCount is 0, add -1 instance (take one away). Make sure your minimum is set to 1 or more (it is recommended 2 minimum, in two separate availability zones for High Availability).

enter image description here

like image 32
Max Avatar answered Nov 04 '22 00:11

Max


Following up on this as I just had the same problem. The solution proposed by @Max is on the right track, but a slight tweak on the numbers is needed.

1) Ensure minimum instance count and maximum instance count are set as precautions

2) Set the following parameters Trigger Measurement: UnHealthyHostCount Trigger statistic: Maximum Unit of measurement: Count Upper threshold: 0 Upper breach scale increment: 1 Lower threshold: 1 Lower breach scale increment: -1

like image 39
packet_sniffer Avatar answered Nov 04 '22 02:11

packet_sniffer