-
Notifications
You must be signed in to change notification settings - Fork 4k
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
feat(lambda): autoscaling for lambda aliases #8883
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks mostly good to me. A few small comments below.
* | ||
* @param options Autoscaling options | ||
*/ | ||
public addAutoScaling(options: AutoScalingOptions): IScalableFunctionAttribute { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this be a better user experience if we change this to a getter autoscaling
that (instantiates, if not already, and) returns scalableAlias
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we might want to keep the same pattern as we have in all other L2 which implements autoscaling (ecs, ddb, ec2)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with returning IScalableFunctionAttribute
in the addAutoScaling()
method.
My question is if this should be -
export class ScalableFunctionAttribute extends appscaling.BaseScalableAttribute implements IScalableFunctionAttribute {
Keeps the type expectations in the correct place and any mismatches will be reported at the correct locations by the compiler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, you are right, I have change it!
packages/@aws-cdk/aws-lambda/lib/scalable-function-attribute.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/aws-lambda/lib/scalable-function-attribute.ts
Outdated
Show resolved
Hide resolved
* Allowed values: 0.1 - 0.9. | ||
*/ | ||
readonly utilizationTarget: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a nice default we can configure here? 0.9 maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ping. This comment is not addressed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no good default here, every use case will have a different "best" target value, depending on the customer provision concurrency value, target cost and other usage pattern, requiring the value here makes the customer fully aware of the cost associate with the value.
* Allowed values: 0.1 - 0.9. | ||
*/ | ||
readonly utilizationTarget: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ping. This comment is not addressed.
* | ||
* @param options Autoscaling options | ||
*/ | ||
public addAutoScaling(options: AutoScalingOptions): IScalableFunctionAttribute { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with returning IScalableFunctionAttribute
in the addAutoScaling()
method.
My question is if this should be -
export class ScalableFunctionAttribute extends appscaling.BaseScalableAttribute implements IScalableFunctionAttribute {
Keeps the type expectations in the correct place and any mismatches will be reported at the correct locations by the compiler.
packages/@aws-cdk/aws-lambda/lib/scalable-function-attribute.ts
Outdated
Show resolved
Hide resolved
* | ||
* Allowed values: 0.1 - 0.9. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. Drop this in favour of the documentation on utilizationTarget
property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have removed it in all places you commented on, since I rename the file it does not show it.
maxCapacity: 20, | ||
}); | ||
|
||
new cdk.CfnOutput(this, 'Output', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new cdk.CfnOutput(this, 'Output', { | |
new cdk.CfnOutput(this, 'FunctionName', { |
*/ | ||
public scaleOnUtilization(options: UtilizationScalingOptions) { | ||
if ( !Token.isUnresolved(options.utilizationTarget) && (options.utilizationTarget < 0.1 || options.utilizationTarget > 0.9)) { | ||
throw new Error('Utilization Target should be between 0.1 and 0.9.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw new Error('Utilization Target should be between 0.1 and 0.9.'); | |
throw new Error(`Utilization Target should be between 0.1 and 0.9. Found ${options.utilizationTarget}`); |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
@Mergifyio refresh |
Add support for autoscaling provisioned concurrency on lambda (closes #6400).
To set autoscaling on a function alias use the
addAutoScaling()
method:It's possible to set PC on a function version, why didn't you add this option?
Following guidance from @iph:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license