Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws-lambda: Simplify Lambda provisioned concurrency autoscaling #6400

Closed
1 task
pahud opened this issue Feb 22, 2020 · 2 comments · Fixed by #8883
Closed
1 task

aws-lambda: Simplify Lambda provisioned concurrency autoscaling #6400

pahud opened this issue Feb 22, 2020 · 2 comments · Fixed by #8883
Assignees
Labels
@aws-cdk/aws-lambda Related to AWS Lambda effort/large Large work item – several weeks of effort feature-request A feature should be added or improved.

Comments

@pahud
Copy link
Contributor

pahud commented Feb 22, 2020

Provisioned concurrency for Lambda function is a huge announcement last year in re:Invent and the Lambda developer guide has a chapter talking about how to configure provisioned concurrency auto scaling with target tracking with AWS CLI like this:

$ aws lambda put-provisioned-concurrency-config --function-name my-function \
--qualifier BLUE --provisioned-concurrent-executions 100
{
    "Requested ProvisionedConcurrentExecutions": 100,
    "Allocated ProvisionedConcurrentExecutions": 0,
    "Status": "IN_PROGRESS",
    "LastModified": "2019-11-21T19:32:12+0000"
}
$ aws application-autoscaling register-scalable-target --service-namespace lambda \
      --resource-id function:my-function:BLUE --min-capacity 1 --max-capacity 100 \
      --scalable-dimension lambda:function:ProvisionedConcurrency
$ aws application-autoscaling put-scaling-policy --service-namespace lambda \
--scalable-dimension lambda:function:ProvisionedConcurrency --resource-id function:my-function:BLUE \
--policy-name my-policy --policy-type TargetTrackingScaling \
--target-tracking-scaling-policy-configuration '{ "TargetValue": 0.7, "PredefinedMetricSpecification": { "PredefinedMetricType": "LambdaProvisionedConcurrencyUtilization" }}'
{
    "PolicyARN": "arn:aws:autoscaling:us-east-2:123456789012:scalingPolicy:12266dbb-1524-xmpl-a64e-9a0a34b996fa:resource/lambda/function:my-function:BLUE:policyName/my-policy",
    "Alarms": [
        {
            "AlarmName": "TargetTracking-function:my-function:BLUE-AlarmHigh-aed0e274-xmpl-40fe-8cba-2e78f000c0a7",
            "AlarmARN": "arn:aws:cloudwatch:us-east-2:123456789012:alarm:TargetTracking-function:my-function:BLUE-AlarmHigh-aed0e274-xmpl-40fe-8cba-2e78f000c0a7"
        },
        {
            "AlarmName": "TargetTracking-function:my-function:BLUE-AlarmLow-7e1a928e-xmpl-4d2b-8c01-782321bc6f66",
            "AlarmARN": "arn:aws:cloudwatch:us-east-2:123456789012:alarm:TargetTracking-function:my-function:BLUE-AlarmLow-7e1a928e-xmpl-4d2b-8c01-782321bc6f66"
        }
    ]
}

In the latest aws-cdk v1.25.0 we start supporting aws-applicationautoscaling with Lambda(PR) and I have yet another PR(#6394 ) to make it complete. We should be able to build the provisioned concurrency autoscaling like this

圖片

To make it even simplied, as the provisioned concurrency can be configured over any lambda function version or alias, we probably can extend the lambda.Version class by adding a scaleOnProvisionedConcurrency function like this

  public scaleOnProvisionedConcurrency(props: ScaleProvisionedConcurrencyProps): applicationautoscaling.TargetTrackingScalingPolicy {
      return new applicationautoscaling.ScalableTarget(this, 'ScalableLambdaTarget', {
      serviceNamespace: applicationautoscaling.ServiceNamespace.LAMBDA,
      maxCapacity: props.max,
      minCapacity: props.min,
      resourceId: `function:${this.functionName}:${this.version}`,
      scalableDimension: 'lambda:function:ProvisionConcurrency',
    })
      .scaleToTrackMetric('PceTracking', {
        targetValue: props.target,
        predefinedMetric: applicationautoscaling.PredefinedMetric.LAMBDA_PROVISIONED_CONCURRENCY_UTILIZATION,
      });
  }

And in this case, all lambda function alias can have autoscaling capabilities. Sample code here

圖片

Any thoughts?

Use Case

To make any AWS Lambda function version or alias very easy to enable its provisioned concurrency auto scaling capabilities.

Proposed Solution

described above

Other

  • [v] 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

This is a 🚀 Feature Request

@pahud pahud added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Feb 22, 2020
@pahud pahud changed the title feat(lambda): Simplify Lambda provisioned concurrency autoscaling aws-lambda: Simplify Lambda provisioned concurrency autoscaling Feb 22, 2020
@SomayaB SomayaB added the @aws-cdk/aws-lambda Related to AWS Lambda label Feb 24, 2020
@nija-at
Copy link
Contributor

nija-at commented Feb 25, 2020

Thanks for filing this issue. In general, we should have this feature included into the CDK.

There's a few things we should consider during the start of implementation -

  • be careful about how we connect this to versions. We have a reported bug that causes versions to not update as expected - Deploying new version of lambda function #5334. It might turn out that we have to fix up this behaviour before implementing this feature.
  • work out what the right location for this package would be. There are two options, either in the @aws-cdk/aws-lambda package or a new @aws-cdk/aws-autoscaling-targets package.

Finally, the API signatures you've suggested need to be tuned for a more ergonomic customer experience.

@nija-at nija-at added effort/large Large work item – several weeks of effort and removed needs-triage This issue or PR still needs to be triaged. labels Feb 25, 2020
@eladb
Copy link
Contributor

eladb commented Mar 17, 2020

Related: #6771

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-lambda Related to AWS Lambda effort/large Large work item – several weeks of effort feature-request A feature should be added or improved.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants