Amazon AutoScale help with Scale In

I think i have a problem with autoscaling. I have many EC2 servers running, i am not sure if i need that much.

Can anyone check my scale out and scale in policy and give some suggestions to improve ?

scale out policy

scale in policy

Anything we can do to improve scale in policy, so unwanted servers get terminated properly, before i had an issue, where servers get terminated quickly, increasing load, then new instance spawn like a LOOP.

EDIT 1: As per suggestion from /user/Toger, i increased scale out cpu load from 30 to 60. New policy Imgur: The magic of the Internet


Related discussions:

Hard to say without a load test. Is 20% the equivalent of ‘idle’, or is it realistic under load? How many servers do you have, and what happens if you synthetically remove one from rotation? What level of cpu usage are you comfortable with?

You may need to raise the reshold for scale down up to say 30% to cause scale in.

For your issue with scale in causing a scale up.

https://docs.aws.amazon.com/autoscaling/latest/userguide/Cooldown.html

This may not actually be what you need though. In general, scale up fast, scale in slow.

You probably need to adjust your triggers to something that would work better for you.

Thanks for the reply, done it in panic, as sites was having down time due to instance get deleted/created problem.

I will increase scale up from 30% to 60%.

Here is new scale out policy

First optimise your boot time + time to start the service, try using pre-baked AMI’s or similar ideas to reduce the amount of bootstrapping required.

You could also consider scaling up 2 instances at a time and down 1 instance at a time.

Here is my updated scale in policy

This alarm will trigger when the blue line goes below the red line for 15 datapoints within 15 minutes

This is fine or any change required ?

^(Hi, I’m a bot for linking direct images of albums with only 1 image)

**

**

^[1](GitHub - AUTplayed/imguralbumbot: A reddit bot for linking direct images of single-picture albums · GitHub) ^^| ^[2](imguralbumbot/README.md at master · AUTplayed/imguralbumbot · GitHub) ^^| ^[3](Reddit) ^^| ^[4](Reddit) ^^| ^[5](Reddit)


  1. Source ↩︎

  2. Why? ↩︎

  3. Creator ↩︎

  4. ignoreme ↩︎

  5. deletthis ↩︎

Thanks, checking now.

What instance size are you using?

General AutoScaling Thoughts:

  • Set Cooldown to 600 Seconds. Cooldown is a delay added that prevents autoscaling events from triggering too quickly. So Cooldown tells the ASG, “do something, and then wait a bit”. This prevents the ASG flapping instances up and down.

  • Set a Grace period long enough that the instance will come into service, and register as health with the Load Balancer.

  • If you are using a Load Balancer, set a drain time for instances being removed from the ELB and terminated. This allows an instance to finish what it was doing before being killed off.

  • Consider using different metrics for Scaling. Latency seen at the LB, or Request Count could be used here, although CPU is a trusted favourite of mine.

This is a great start. One thing you should do is monitor your load balancer 90, 95, and 99th percentile response times. Don’t scale on them yet, but try to figure out what “slow” looks like. You might find out that your limiting factor is actually memory usage, not CPU.

Biggest pitfall I’ve run into is trying to scale on more than one metric could wind up thrashing “high CPU I scale out, low memory I scale in. Aaaaaaah!”

Thanks, already using custom API with everything installed. Only thing user script do is add my SSH key.

Thanks, i have to install custom monitoring to get memory usage to show up ? Not yet checked that.

i am using t2.small

Set Cooldown to 600 Seconds.

Done

Set a Grace period long enough that the instance will come into service, and register as health with the Load Balancer.

This is set to 600, i have custom AMI with everything pre installed.

If you are using a Load Balancer, set a drain time for instances

This was disabled, i enabled with 300 seconds.

Consider using different metrics for Scaling. Latency seen at the LB, or Request Count could be used here, although CPU is a trusted favourite of mine.

I am using CPU + Latency now.

Today it look better, no down time, but i feel like i need to optimise, so we don’t over provision, saving some cost.

Sorry, I’ve been neck deep in ECS lately which has that out of the box. But yeah, EC2 you’ll have to add a custom metric, though there are some easily googlable examples of how to do this, I think one “official” from aws

T2.Small?

Scale out @30% CPU, Scale in @10%.

A t2.small will cap at 40% CPU.

And t2.small instance goes over 20% CPU, it starts consuming credits. When it goes under, it starts gaining them.

Monitor Burstable Credit Closely.