Can you create your own EC2 autoscaling triggers?

When using the autoscaling group in EC2, the documentation says that you can start new servers according to the cloudwatch metrics. Can I start new instances myself?

For example, an application has an internal element queue, and as soon as this queue hits the threshold, it sends an EC2 notification to add more servers to the group.

Is it possible?

+4
source share
2 answers

I found the answer is yes and the supporting document is here: http://docs.amazonwebservices.com/AutoScaling/latest/DeveloperGuide/scaling_typesof.html

+2
source

For the benefit of users who visit this answer in the future, here is a more detailed explanation:

EC2 allows you to set / change the capacity of your auto-scale group manually, according to the schedule or on demand, as indicated in the docs .

However, the term manual scaling can be somewhat misleading, because, like almost every aspect of AWS, everything you can do manually can be written either through the CLI or through the SDK.

In the case of the EC2 auto-scaling group, the capacity is configured and can be dynamically changed at runtime - changing the capacity will automatically add or remove instances.

Thus, in this case, the solution will be to detect life cycle events specific to your application in your application code, and in response to these events, use the appropriate AWS SDK to change the capacity of your autoscale group.

In ruby, this can be done as follows (Examples taken from AWS API Documentation ):

autoscaling = Aws::AutoScaling::Client.new( region: region_name, credentials: credentials ) resp = autoscaling.set_desired_capacity( # required auto_scaling_group_name: "ResourceName", # required desired_capacity: 1, honor_cooldown: true, ) 
+2
source

Source: https://habr.com/ru/post/1416444/


All Articles