question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sagemaker autoscaling not working using boto3 client

See original GitHub issue

Describe the bug I want to programmatically configure auto-scaling in AWS Sagemaker. I am using the official boto3 documentation. First step is to register a scalable target. Second step is to define a scaling policy on the target. The first step works fine. Second step gets executed but it wont change the metric value .

Steps to reproduce

#Step - 1  -- This step works fine. Max and Min capacities are updated as passed in the arguments
        autoscaling.register_scalable_target(
            ServiceNamespace='sagemaker',
            ResourceId='endpoint/test-20450427-0648/variant/test-20450427-0648-model-kp-vrjfgs268gfljnhs5ra',
            ScalableDimension='sagemaker:variant:DesiredInstanceCount',
            MinCapacity=1,
            MaxCapacity=10,
            RoleARN='arn:aws:iam::654763378725:role/ml-sagemaker'
        )

#Step-2  -- This step is not working. 
        autoscaling.put_scaling_policy(
            PolicyName='InvocationsPerInstanceCustom',
            ServiceNamespace='sagemaker',
            ResourceId='endpoint/test-20450427-0648/variant/test-20450427-0648-model-kp-vrjfgs268gfljnhs5ra',
            ScalableDimension='sagemaker:variant:DesiredInstanceCount',
            PolicyType='TargetTrackingScaling',
            TargetTrackingScalingPolicyConfiguration={
                "TargetValue": 122.0,
                "PredefinedMetricSpecification": {"PredefinedMetricType": "SageMakerVariantInvocationsPerInstance"},
                'ScaleOutCooldown': 60,
                'ScaleInCooldown': 60
            }
        )

Expected behavior Step 2 should update the target value of metric SageMakerVariantInvocationsPerInstance to 122. But it remains empty when checked on AWS console . ScaleOutCooldown and ScaleInCooldown also should be set to 60 but they show default value 300. Debug logs No error message is repoted.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:26 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
pradozcommented, Aug 10, 2022

@georgebakas

PolicyName="SagemakerEndpointInvocationScalingPolicy ", …there is a space here^

1reaction
stobrien89commented, May 11, 2021

Hi @singh0777,

Glad you were able to get it working! I don’t think you did anything wrong here— it seems like, in theory, you should be able to apply custom policies to a target regardless of whether or not a ‘built-in’ policy has already been applied. This may be a bug with the Sagemaker console; I’ve asked the team to elaborate on what the expected behavior should be and am currently waiting on a response.

I have a hunch that your custom policy was actually being applied to the target, but it was not displaying in the console due to the name. I’ll let you know as soon as I have more information!

Read more comments on GitHub >

github_iconTop Results From Across the Web

SageMaker — Boto3 Docs 1.26.32 documentation - AWS
class SageMaker. Client ¶. A low-level client representing Amazon SageMaker Service ... SageMaker does not split the files any further for model training....
Read more >
Configuring autoscaling inference endpoints in Amazon ...
In this post, we showcase how to configure using the boto3 SDK for Python and outline different scaling policies and patterns.
Read more >
how to add autoscaling policy to an sagemaker endpoint via ...
Terraform documentation has all the resources need to create the asynchornous endpoint but not sure if it is possible to add auto scaling...
Read more >
Session — sagemaker 2.124.0 documentation
If not provided, one is created with default AWS configuration chain. sagemaker_client (boto3.SageMaker.Client) – Client which makes Amazon SageMaker ...
Read more >
how to set up autoscaling for async sagemaker endpoint?
working with an example documented here ... client = boto3.client( "application-autoscaling") resource_id = ( "endpoint/" + endpoint_name + "/variant/" + ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found