36

On AWS, you can create an auto scaling policy which scales based on "Application Load Balancer Request Count Per Target".

Like this:

enter image description here

This has a min of 1 instance and a max of 5. It should aim to achieve 10 "Request count per target" for my ElbTargetGroup.

My question is, what is "Application Load Balancer Request Count Per Target"?

Is this:

  • Number of active connections to targets from the load balancer divided by number of targets?
  • Number of requests per 5 minutes divided by number of targets?
  • Number of requests per 1 minute divided by number of targets?

The documentation here just says:

The average number of requests received by each target in a target group. You must specify the target group using the TargetGroup dimension.

Also, how long does it have to be over that target for it to start creating new instances? The main reason I ask is that I have sent many requests to this load balancer, but scaling events aren't being triggered.

ThePerson
  • 3,048
  • 8
  • 43
  • 69
  • 6
    good question ! – Abdennour TOUMI Dec 02 '17 at 19:40
  • 1
    Did you ever find an answer to this question as I don't think the below answer from AstroTom is correct as nowhere does it let you set this metric as either 5 minutes or 1 minute or enable detailed monitoring for it as it is not an EC2 metric, and I can only find the detailed monitoring option for EC2 instances and not ALB's. Thanks. – andrewdixon Apr 17 '18 at 11:06
  • I'd also be interested to know if you ever found an answer as I am seeing the same behaviour – fatlog May 03 '18 at 12:35
  • 1
    One way to find out for sure is to create the scaling policy, then go to the CloudWatch page. The policy will have created two alarms that it uses to manage scaling. You can look at the definition of the alarm to find out exactly what will cause it to go into alarm state (especially pay attention to the "Threshold" field). – Matthew Feb 12 '19 at 16:03
  • I updated my answer below to show that the ALB metric is sampled at 1 minute intervals. Thanks @andrewdixon – AstroTom May 09 '22 at 12:20

2 Answers2

14

The answer is your first choice: "Number of active connections to targets from the load balancer divided by number of targets" The ELB metrics are all 1 minute, as quoted by Hagen above.

You can see all the metric definitions for load balancers in the AWS ALB doc.

Note, that there is both a RequestCount and RequestCountPerTarget where the latter is the former divided by the number of active targets.

You can see both these metrics in the CloudWatch console, but more simply in the EC2 console. Select Target Groups on the left pane and then the Monitoring tab. (Note that there is a lot of overlap between the monitoring tab of Target Groups and Monitoring in the Load Balancer screen)

Although the Load Balancer metrics are every 1 minute, if you used EC2 metrics (like CPU) they are only every 5 minutes by default unless you change your CloudWatch settings to turn on detailed monitoring to get metrics every minute. You pay extra for detailed metrics.

Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
AstroTom
  • 370
  • 3
  • 9
  • 1
    I don't think this is correct. This metric accounts for the total amount of requests that have gone through the ELB, not the (average) number of currently active connections. It's a throughput metric, not a load metric. This means you cannot use it to scale with if for example you have a defined max amount of connections you know your backends can handle simultaneously and wanted scale up and down based off of that. You have to calculate your backend's throughput, ie how many requests it can handle in one minute to use it. – eirc Sep 22 '22 at 10:32
13

RequestCountPerTarget is a load balancer metric. The ELB metrics are always over 1 minute, as outlined in the documentation:

Elastic Load Balancing reports metrics to CloudWatch only when requests are flowing through the load balancer. If there are requests flowing through the load balancer, Elastic Load Balancing measures and sends its metrics in 60-second intervals. If there are no requests flowing through the load balancer or no data for a metric, the metric is not reported.

So if you stick to this metric, there is no need to pay for detailed EC2 instance metrics. This is only relevant if you need to use something like the CPU utilization on the instances.

Hagen
  • 391
  • 2
  • 4