aws-cdk-lib/aws-autoscaling: scaleOnMemoryUtilization() Method for EC2 Auto Scaling Groups
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the feature
Currently, AWS CDK provides a convenient `scaleOnCpuUtilization()` method for setting up target-tracking scaling policies based on the native `CPUUtilization` metric for an Auto Scaling Group. However, there is no equivalent predefined method for scaling based on memory utilization.
Since monitoring memory usage requires the CloudWatch agent to be installed on EC2 instances, and the memory metrics are emitted as custom metrics, CDK users must manually define the metric and use `scaleOnMetric()`. It would improve developer experience and code clarity if CDK provided a predefined helper method like `scaleOnMemoryUtilization()` to wrap this pattern.
### Use Case
```
const asg = new autoscaling.AutoScalingGroup(this, 'DefaultAsg', {
vpc,
vpcSubnets
minCapacity
maxCapacity
desiredCapacity
launchTemplate
});
asg.scaleOnMemoryUtilization('MemoryScaling', {
targetUtilizationPercent: 80,
cooldown: Duration.seconds(60),
estimatedInstanceWarmup: Duration.seconds(120),
});
```
### Proposed Solution
_No response_
### Other Information
_No response_
### Acknowledgements
- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change
### CDK version used
2.164.1
### Environment details (OS name and version, etc.)
windows 10
Contributor guide
Research direction
Start by reading the existing scaleOnCpuUtilization() and scaleOnMetric() entry points to understand how target-tracking policies and custom metrics are exposed. Compare their behavior with the requested scaleOnMemoryUtilization() example, then verify that the helper supports the stated target, cooldown, and warmup options and produces the intended memory-based scaling policy.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, infrastructure
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100