Skip to content

(aws-autoscaling/aws-applicationautoscaling): StepScalingPolicy supports at most 40 steps #26215

@SamStephens

Description

@SamStephens

Describe the bug

If you create a StepScalingPolicy with more than 40 steps, the Cloudformation deployment fails with the message "There can be at most 20 step adjustments per scaling policy".

The reason the limit is 40 and not 20 is because StepScalingPolicy creates two policies, an UpperPolicy and a LowerPolicy, each containing half the steps.

Expected Behavior

The deployment succeeds, with the steps split across the required number of policies.

If I've misunderstood the code, and there's a reason to specifically have two policies, I'd expect a build time failure from CDK when the number of steps exceeds 40, rather than a build time failure.

Current Behavior

Cloudformation deployment fails with the message "There can be at most 20 step adjustments per scaling policy".

Reproduction Steps

Starting with a Fargate Service and an SQS queue (I'm trying to reproduce the tracking policy https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-target-tracking-metric-math.html describes without using metric math).

        maximum_number_of_tasks = 50
        desired_messages_per_task = 20

        scaling = service.auto_scale_task_count(
            min_capacity=1,
            max_capacity=maximum_number_of_tasks,
        )

        scaling_steps = [
            aws_applicationautoscaling.ScalingInterval(
                lower=step_number * desired_messages_per_task,
                upper=step_number * (desired_messages_per_task + 1) - 1,
                change=step_number + 1,
            )
            for step_number
            in range(0, maximum_number_of_tasks)
        ]

        scaling.scale_on_metric(
            id="Track visible messages per task",
            metric=queue.metric_approximate_number_of_messages_visible(
                statistic="Average",
                period=Duration.minutes(1),
            ),
            adjustment_type=aws_autoscaling.AdjustmentType.EXACT_CAPACITY,
            scaling_steps=scaling_steps,
            cooldown=Duration.minutes(3),
        )

Possible Solution

Allow for more than two scaling policies to be created (this may not make sense, my understanding of these policies is not great).

Additional Information/Context

No response

CDK CLI Version

2.86.0 (build 1130fab)

Framework Version

2.81.0

Node.js Version

v16.18.1

OS

Ubuntu (Windows Subsystem for Linux)

Language

Python

Language Version

3.9.7

Other information

No response

Metadata

Metadata

Assignees

Labels

@aws-cdk/aws-sqsRelated to Amazon Simple Queue ServicebugThis issue is a bug.effort/mediumMedium work item – several days of effortp2

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions