class ScalableTaskCount (construct)
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.ECS.ScalableTaskCount |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsecs#ScalableTaskCount |
Java | software.amazon.awscdk.services.ecs.ScalableTaskCount |
Python | aws_cdk.aws_ecs.ScalableTaskCount |
TypeScript (source) | aws-cdk-lib » aws_ecs » ScalableTaskCount |
Implements
IConstruct
, IDependable
The scalable attribute representing task count.
Example
declare const cluster: ecs.Cluster;
const loadBalancedFargateService = new ecsPatterns.ApplicationLoadBalancedFargateService(this, 'Service', {
cluster,
memoryLimitMiB: 1024,
desiredCount: 1,
cpu: 512,
taskImageOptions: {
image: ecs.ContainerImage.fromRegistry("amazon/amazon-ecs-sample"),
},
});
const scalableTarget = loadBalancedFargateService.service.autoScaleTaskCount({
minCapacity: 1,
maxCapacity: 20,
});
scalableTarget.scaleOnCpuUtilization('CpuScaling', {
targetUtilizationPercent: 50,
});
scalableTarget.scaleOnMemoryUtilization('MemoryScaling', {
targetUtilizationPercent: 50,
});
Initializer
new ScalableTaskCount(scope: Construct, id: string, props: ScalableTaskCountProps)
Parameters
- scope
Construct
- id
string
- props
Scalable
Task Count Props
Constructs a new instance of the ScalableTaskCount class.
Construct Props
Name | Type | Description |
---|---|---|
dimension | string | Scalable dimension of the attribute. |
max | number | Maximum capacity to scale to. |
resource | string | Resource ID of the attribute. |
role | IRole | Role to use for scaling. |
service | Service | Service namespace of the scalable attribute. |
min | number | Minimum capacity to scale to. |
dimension
Type:
string
Scalable dimension of the attribute.
maxCapacity
Type:
number
Maximum capacity to scale to.
resourceId
Type:
string
Resource ID of the attribute.
role
Type:
IRole
Role to use for scaling.
serviceNamespace
Type:
Service
Service namespace of the scalable attribute.
minCapacity?
Type:
number
(optional, default: 1)
Minimum capacity to scale to.
Properties
Name | Type | Description |
---|---|---|
node | Node | The tree node. |
node
Type:
Node
The tree node.
Methods
Name | Description |
---|---|
scale | Scales in or out to achieve a target CPU utilization. |
scale | Scales in or out to achieve a target memory utilization. |
scale | Scales in or out based on a specified metric value. |
scale | Scales in or out to achieve a target Application Load Balancer request count per target. |
scale | Scales in or out based on a specified scheduled time. |
scale | Scales in or out to achieve a target on a custom metric. |
to | Returns a string representation of this construct. |
OnCpuUtilization(id, props)
scalepublic scaleOnCpuUtilization(id: string, props: CpuUtilizationScalingProps): void
Parameters
- id
string
- props
Cpu
Utilization Scaling Props
Scales in or out to achieve a target CPU utilization.
OnMemoryUtilization(id, props)
scalepublic scaleOnMemoryUtilization(id: string, props: MemoryUtilizationScalingProps): void
Parameters
- id
string
- props
Memory
Utilization Scaling Props
Scales in or out to achieve a target memory utilization.
OnMetric(id, props)
scalepublic scaleOnMetric(id: string, props: BasicStepScalingPolicyProps): void
Parameters
- id
string
- props
Basic
Step Scaling Policy Props
Scales in or out based on a specified metric value.
OnRequestCount(id, props)
scalepublic scaleOnRequestCount(id: string, props: RequestCountScalingProps): void
Parameters
- id
string
- props
Request
Count Scaling Props
Scales in or out to achieve a target Application Load Balancer request count per target.
OnSchedule(id, props)
scalepublic scaleOnSchedule(id: string, props: ScalingSchedule): void
Parameters
- id
string
- props
Scaling
Schedule
Scales in or out based on a specified scheduled time.
ToTrackCustomMetric(id, props)
scalepublic scaleToTrackCustomMetric(id: string, props: TrackCustomMetricProps): void
Parameters
- id
string
- props
Track
Custom Metric Props
Scales in or out to achieve a target on a custom metric.
String()
topublic toString(): string
Returns
string
Returns a string representation of this construct.