Experimental
@aws-cdk/aws-sagemaker-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.
ScalableInstanceCount
A scalable sagemaker endpoint attribute.
Example
import * as sagemaker from '@aws-cdk/aws-sagemaker-alpha';
declare const model: sagemaker.Model;
const variantName = 'my-variant';
const endpointConfig = new sagemaker.EndpointConfig(this, 'EndpointConfig', {
instanceProductionVariants: [
{
model: model,
variantName: variantName,
},
]
});
const endpoint = new sagemaker.Endpoint(this, 'Endpoint', { endpointConfig });
const productionVariant = endpoint.findInstanceProductionVariant(variantName);
const instanceCount = productionVariant.autoScaleInstanceCount({
maxCapacity: 3
});
instanceCount.scaleOnInvocations('LimitRPS', {
maxRequestsPerSecond: 30,
});
import aws_cdk.aws_sagemaker_alpha as sagemaker
# model: sagemaker.Model
variant_name = "my-variant"
endpoint_config = sagemaker.EndpointConfig(self, "EndpointConfig",
instance_production_variants=[sagemaker.InstanceProductionVariantProps(
model=model,
variant_name=variant_name
)
]
)
endpoint = sagemaker.Endpoint(self, "Endpoint", endpoint_config=endpoint_config)
production_variant = endpoint.find_instance_production_variant(variant_name)
instance_count = production_variant.auto_scale_instance_count(
max_capacity=3
)
instance_count.scale_on_invocations("LimitRPS",
max_requests_per_second=30
)
import software.amazon.awscdk.services.sagemaker.alpha.*;
Model model;
String variantName = "my-variant";
EndpointConfig endpointConfig = EndpointConfig.Builder.create(this, "EndpointConfig")
.instanceProductionVariants(List.of(InstanceProductionVariantProps.builder()
.model(model)
.variantName(variantName)
.build()))
.build();
Endpoint endpoint = Endpoint.Builder.create(this, "Endpoint").endpointConfig(endpointConfig).build();
IEndpointInstanceProductionVariant productionVariant = endpoint.findInstanceProductionVariant(variantName);
ScalableInstanceCount instanceCount = productionVariant.autoScaleInstanceCount(EnableScalingProps.builder()
.maxCapacity(3)
.build());
instanceCount.scaleOnInvocations("LimitRPS", InvocationsScalingProps.builder()
.maxRequestsPerSecond(30)
.build());
// Install: dotnet add package Amazon.CDK.AWS.Sagemaker.Alpha
using Amazon.CDK.AWS.Sagemaker.Alpha;
Model model;
var variantName = "my-variant";
var endpointConfig = new EndpointConfig(this, "EndpointConfig", new EndpointConfigProps {
InstanceProductionVariants = new [] { new InstanceProductionVariantProps {
Model = model,
VariantName = variantName
} }
});
var endpoint = new Endpoint(this, "Endpoint", new EndpointProps { EndpointConfig = endpointConfig });
var productionVariant = endpoint.FindInstanceProductionVariant(variantName);
var instanceCount = productionVariant.AutoScaleInstanceCount(new EnableScalingProps {
MaxCapacity = 3
});
instanceCount.ScaleOnInvocations("LimitRPS", new InvocationsScalingProps {
MaxRequestsPerSecond = 30
});
// Install: go get github.com/aws/aws-cdk-go/awscdksagemakeralpha/v2
import "github.com/aws/aws-cdk-go/awscdksagemakeralpha"
var model Model
variantName := "my-variant"
endpointConfig := sagemaker.NewEndpointConfig(this, jsii.String("EndpointConfig"), &EndpointConfigProps{
InstanceProductionVariants: []InstanceProductionVariantProps{
&InstanceProductionVariantProps{
Model: model,
VariantName: variantName,
},
},
})
endpoint := sagemaker.NewEndpoint(this, jsii.String("Endpoint"), &EndpointProps{
EndpointConfig: EndpointConfig,
})
productionVariant := endpoint.FindInstanceProductionVariant(variantName)
instanceCount := productionVariant.AutoScaleInstanceCount(&EnableScalingProps{
MaxCapacity: jsii.Number(3),
})
instanceCount.ScaleOnInvocations(jsii.String("LimitRPS"), &InvocationsScalingProps{
MaxRequestsPerSecond: jsii.Number(30),
})
Initializer
new ScalableInstanceCount(scope: Construct, id: string, props: ScalableInstanceCountProps)
ScalableInstanceCount(scope: Construct, id: str, props: ScalableInstanceCountProps)
new ScalableInstanceCount(Construct scope, String id, ScalableInstanceCountProps props)
new ScalableInstanceCount(Construct scope, string id, ScalableInstanceCountProps props)
NewScalableInstanceCount(Scope Construct, Id *string, Props ScalableInstanceCountProps)
Construct Props
maxCapacitynumbermax_capacityint | floatmaxCapacityNumberMaxCapacitydoubleMaxCapacity*float64required#serviceNamespaceServiceNamespaceservice_namespaceServiceNamespaceserviceNamespaceServiceNamespaceServiceNamespaceServiceNamespaceServiceNamespaceServiceNamespacerequired#Properties
envResourceEnvironmentenvResourceEnvironmentenvResourceEnvironmentEnvResourceEnvironmentEnvResourceEnvironmentrequired#notes
For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.
For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.
scalableTargetRefScalableTargetReferencescalable_target_refScalableTargetReferencescalableTargetRefScalableTargetReferenceScalableTargetRefScalableTargetReferenceScalableTargetRefScalableTargetReferencerequired#Methods
isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#notes · 1 parameter · returns
Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.
Parameters
xxxxX— Any object.
Returns: true if x is an object created from a class which extends Construct.
scaleOnInvocations(id: string, props: InvocationsScalingProps): voiddef scale_on_invocations(self, id: str, props: InvocationsScalingProps) -> Nonepublic void scaleOnInvocations(String id, InvocationsScalingProps props)public void ScaleOnInvocations(string id, InvocationsScalingProps props)func ScaleOnInvocations(Id *string, Props InvocationsScalingProps)#toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.
1 parameter · returns
Parameters
mixinsmixinsmixinsmixinsMixins— The mixins to apply.
Returns: This construct for chaining