5

I use t2.medium as a front servers at my architecture.

Usually AWS autoscaling use "CPU Utilization", but for t2 it's a bit tricky. When "CPU Credit Balance" is low, t2.medium "CPU Utilization" can be maximum 20%, so autoscaling will not detect alert.

Is there any way to scale t2 instances?

updated: trying to use custom metrics https://github.com/shtrihstr/cloudwatch

2 Answers 2

4

T2 instances should be absolutely avoided in scenarios where your applications consistently consume their credits, precisely due to this kind of issues with the CPU credits system provided by AWS. If your application is CPU intensive in a consistent way, you should better go for C3/C4 instances, which have the same CPU/Memory ratios (except t2.large which, is equivalent to M4.large).

Autoscaling works because you assume that the capacity of your cluster is consistent and proportional to the number of instances, which may be not be true when using T2 instances in some scenarios. Once some of your ASG instances (not necessarilly all of them, due to different launch dates, autoscaling events, etc.) starve their credits, all of the metrics THOSE INSTANCES submit to Cloudwatch are degrading the consistency of the ASG metrics, rendering them useless to take good decisions for Autoscaling.

3

My approach is to scale before you run out of CPU credits. A simple way is to define a minimum acceptable credit balance, for me this is 50.

You can do this within CloudWatch. 'Create Alarm', EC2 Metrics-> By Auto Scaling Group.

Select CPUCreditBalance, minimum of 50. This way I can take action when a single instance is likely to become slow before the load balancer removes it from circulation, even if the average balance is within acceptable bounds.

You can create a notification or auto scale.

3
  • Can you please edit your answer to give a bit more detail on how this addresses the problem? It looks like you're saying you scale up when a t2 instance runs out of CPU credits, but that in itself may not solve the problem because the t2 with no CPU credit would still be in the load balancer, responding to requests, as it will likely report healthy to the ELB. If you could take an instance out when it had 0 CPU credit that might work. Alternately some kind of custom way to have the ELB mark the t2 instance unhealthy when the credit balance was zero.
    – Tim
    Jan 24, 2017 at 7:49
  • @Tim The suggestion is to scale out before the credits run out. If you want to scale when any of your instances run out of credits, use the Minimum aggregation rather than Average. Also, a t2 with zero credits doesn't halt entirely. As described in the docs, "performance remains at the baseline performance level" rather than bursting above it. If the baseline performance is unacceptable, you need to either scale out sufficiently in advance before that happens, or you need to use a different instance type.
    – Shannon
    May 17, 2017 at 16:39
  • That still doesn't really address the problem very well. It's best to run constant CPU instances behind a load balancer, rather than t2 types.
    – Tim
    May 17, 2017 at 18:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .