@aws-cdk/aws-applicationautoscaling
Advanced tools
Comparing version 0.13.0 to 0.14.0
export * from './applicationautoscaling.generated'; | ||
export * from './base-scalable-attribute'; | ||
export * from './cron'; | ||
export * from './scalable-target'; | ||
export * from './step-scaling-policy'; | ||
export * from './step-scaling-action'; | ||
export * from './target-tracking-scaling-policy'; |
@@ -8,2 +8,8 @@ "use strict"; | ||
__export(require("./applicationautoscaling.generated")); | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJpbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLHdEQUF3RDtBQUN4RCx3REFBbUQiLCJzb3VyY2VzQ29udGVudCI6WyIvLyBBV1M6OkFwcGxpY2F0aW9uQXV0b1NjYWxpbmcgQ2xvdWRGb3JtYXRpb24gUmVzb3VyY2VzOlxuZXhwb3J0ICogZnJvbSAnLi9hcHBsaWNhdGlvbmF1dG9zY2FsaW5nLmdlbmVyYXRlZCc7XG4iXX0= | ||
__export(require("./base-scalable-attribute")); | ||
__export(require("./cron")); | ||
__export(require("./scalable-target")); | ||
__export(require("./step-scaling-policy")); | ||
__export(require("./step-scaling-action")); | ||
__export(require("./target-tracking-scaling-policy")); | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJpbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLHdEQUF3RDtBQUN4RCx3REFBbUQ7QUFFbkQsK0NBQTBDO0FBQzFDLDRCQUF1QjtBQUN2Qix1Q0FBa0M7QUFDbEMsMkNBQXNDO0FBQ3RDLDJDQUFzQztBQUN0QyxzREFBaUQiLCJzb3VyY2VzQ29udGVudCI6WyIvLyBBV1M6OkFwcGxpY2F0aW9uQXV0b1NjYWxpbmcgQ2xvdWRGb3JtYXRpb24gUmVzb3VyY2VzOlxuZXhwb3J0ICogZnJvbSAnLi9hcHBsaWNhdGlvbmF1dG9zY2FsaW5nLmdlbmVyYXRlZCc7XG5cbmV4cG9ydCAqIGZyb20gJy4vYmFzZS1zY2FsYWJsZS1hdHRyaWJ1dGUnO1xuZXhwb3J0ICogZnJvbSAnLi9jcm9uJztcbmV4cG9ydCAqIGZyb20gJy4vc2NhbGFibGUtdGFyZ2V0JztcbmV4cG9ydCAqIGZyb20gJy4vc3RlcC1zY2FsaW5nLXBvbGljeSc7XG5leHBvcnQgKiBmcm9tICcuL3N0ZXAtc2NhbGluZy1hY3Rpb24nO1xuZXhwb3J0ICogZnJvbSAnLi90YXJnZXQtdHJhY2tpbmctc2NhbGluZy1wb2xpY3knOyJdfQ== |
{ | ||
"name": "@aws-cdk/aws-applicationautoscaling", | ||
"version": "0.13.0", | ||
"version": "0.14.0", | ||
"description": "The CDK Construct Library for AWS::ApplicationAutoScaling", | ||
@@ -55,11 +55,14 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@aws-cdk/assert": "^0.13.0", | ||
"cdk-build-tools": "^0.13.0", | ||
"cfn2ts": "^0.13.0", | ||
"pkglint": "^0.13.0" | ||
"@aws-cdk/assert": "^0.14.0", | ||
"cdk-build-tools": "^0.14.0", | ||
"cfn2ts": "^0.14.0", | ||
"fast-check": "^1.6.1", | ||
"pkglint": "^0.14.0" | ||
}, | ||
"dependencies": { | ||
"@aws-cdk/cdk": "^0.13.0" | ||
"@aws-cdk/aws-cloudwatch": "^0.14.0", | ||
"@aws-cdk/aws-iam": "^0.14.0", | ||
"@aws-cdk/cdk": "^0.14.0" | ||
}, | ||
"homepage": "https://github.com/awslabs/aws-cdk" | ||
} |
151
README.md
@@ -1,2 +0,149 @@ | ||
## The CDK Construct Library for AWS Application Auto-Scaling | ||
This module is part of the [AWS Cloud Development Kit](https://github.com/awslabs/aws-cdk) project. | ||
## AWS Application AutoScaling Construct Library | ||
**Application AutoScaling** is used to configure autoscaling for all | ||
services other than scaling EC2 instances. For example, you will use this to | ||
scale ECS tasks, DynamoDB capacity, Spot Fleet sizes and more. | ||
As a CDK user, you will probably not have to interact with this library | ||
directly; instead, it will be used by other construct libraries to | ||
offer AutoScaling features for their own constructs. | ||
This document will describe the general autoscaling features and concepts; | ||
your particular service may offer only a subset of these. | ||
### AutoScaling basics | ||
Resources can offer one or more **attributes** to autoscale, typically | ||
representing some capacity dimension of the underlying service. For example, | ||
a DynamoDB Table offers autoscaling of the read and write capacity of the | ||
table proper and its Global Secondary Indexes, an ECS Service offers | ||
autoscaling of its task count, an RDS Aurora cluster offers scaling of its | ||
replica count, and so on. | ||
When you enable autoscaling for an attribute, you specify a minimum and a | ||
maximum value for the capacity. AutoScaling policies that respond to metrics | ||
will never go higher or lower than the indicated capacity (but scheduled | ||
scaling actions might, see below). | ||
There are three ways to scale your capacity: | ||
* **In response to a metric**; for example, you might want to scale out | ||
if the CPU usage across your cluster starts to rise, and scale in | ||
when it drops again. | ||
* **By trying to keep a certain metric around a given value**; you might | ||
want to automatically scale out an in to keep your CPU usage around 50%. | ||
* **On a schedule**; you might want to organize your scaling around traffic | ||
flows you expect, by scaling out in the morning and scaling in in the | ||
evening. | ||
The general pattern of autoscaling will look like this: | ||
```ts | ||
const capacity = resource.autoScaleCapacity({ | ||
minCapacity: 5, | ||
maxCapacity: 100 | ||
}); | ||
// Enable a type of metric scaling and/or schedule scaling | ||
capacity.scaleOnMetric(...); | ||
capacity.scaleToTrackMetric(...); | ||
capacity.scaleOnSchedule(...); | ||
``` | ||
### AutoScaling in response to a metric | ||
This type of scaling scales in and out in deterministics steps that you | ||
configure, in response to metric values. For example, your scaling strategy | ||
to scale in response to CPU usage might look like this: | ||
``` | ||
Scaling -1 (no change) +1 +3 | ||
│ │ │ │ │ | ||
├────────┼───────────────────────┼────────┼────────┤ | ||
│ │ │ │ │ | ||
CPU usage 0% 10% 50% 70% 100% | ||
``` | ||
(Note that this is not necessarily a recommended scaling strategy, but it's | ||
a possible one. You will have to determine what thresholds are right for you). | ||
You would configure it like this: | ||
```ts | ||
capacity.scaleOnMetric('ScaleToCPU', { | ||
metric: service.metricCpuUtilization(), | ||
scalingSteps: [ | ||
{ upper: 10, change: -1 }, | ||
{ lower: 50, change: +1 }, | ||
{ lower: 70, change: +3 }, | ||
], | ||
// Change this to AdjustmentType.PercentChangeInCapacity to interpret the | ||
// 'change' numbers before as percentages instead of capacity counts. | ||
adjustmentType: autoscaling.AdjustmentType.ChangeInCapacity, | ||
}); | ||
``` | ||
The AutoScaling construct library will create the required CloudWatch alarms and | ||
AutoScaling policies for you. | ||
### AutoScaling by tracking a metric value | ||
This type of scaling scales in and out in order to keep a metric (typically | ||
representing utilization) around a value you prefer. This type of scaling is | ||
typically heavily service-dependent in what metric you can use, and so | ||
different services will have different methods here to set up target tracking | ||
scaling. | ||
The following example configures the read capacity of a DynamoDB table | ||
to be around 60% utilization: | ||
```ts | ||
const readCapacity = table.autosScaleReadCapacity({ | ||
minCapacity: 10, | ||
maxCapacity: 1000 | ||
}); | ||
readCapacity.scaleOnUtilization({ | ||
targetUtilizationPercent: 60 | ||
}); | ||
``` | ||
### AutoScaling on a schedule | ||
This type of scaling is used to change capacities based on time. It works | ||
by changing the `minCapacity` and `maxCapacity` of the attribute, and so | ||
can be used for two purposes: | ||
* Scale in and out on a schedule by setting the `minCapacity` high or | ||
the `maxCapacity` low. | ||
* Still allow the regular scaling actions to do their job, but restrict | ||
the range they can scale over (by setting both `minCapacity` and | ||
`maxCapacity` but changing their range over time). | ||
The following schedule expressions can be used: | ||
* `at(yyyy-mm-ddThh:mm:ss)` -- scale at a particular moment in time | ||
* `rate(value unit)` -- scale every minute/hour/day | ||
* `cron(mm hh dd mm dow)` -- scale on arbitrary schedules | ||
Of these, the cron expression is the most useful but also the most | ||
complicated. There is a `Cron` helper class to help build cron expressions. | ||
The following example scales the fleet out in the morning, and lets natural | ||
scaling take over at night: | ||
```ts | ||
const capacity = resource.autoScaleCapacity({ | ||
minCapacity: 1, | ||
maxCapacity: 50, | ||
}); | ||
capacity.scaleOnSchedule('PrescaleInTheMorning', { | ||
schedule: autoscaling.Cron.dailyUtc(8), | ||
minCapacity: 20, | ||
}); | ||
capacity.scaleOnSchedule('AllowDownscalingAtNight', { | ||
schedule: autoscaling.Cron.dailyUtc(20), | ||
minCapacity: 1 | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
450853
37
2652
150
3
5
1
+ Added@aws-cdk/aws-iam@^0.14.0
+ Added@aws-cdk/aws-cloudwatch@0.14.1(transitive)
+ Added@aws-cdk/aws-iam@0.14.1(transitive)
+ Added@aws-cdk/cdk@0.14.1(transitive)
+ Added@aws-cdk/cx-api@0.14.1(transitive)
- Removed@aws-cdk/cdk@0.13.0(transitive)
- Removed@aws-cdk/cx-api@0.13.0(transitive)
Updated@aws-cdk/cdk@^0.14.0