Videos
Hey, I'm a huge serverless user, I've built several applications on top of Lambda, Dynamo, S3, EFS, SQS, etc.
But I have never understood why would someone use Provisioned Concurrency, do you know a real use case for this feature?
I mean, if your application is suffering due to cold starts, you can just use the old-school EventBridge ping option and it costs 0, or if you have a critical latency requirement you can just go to Fargate instead of paying for provisioned concurrency, am I wrong?
Lambda automatically scales out for incoming requests, if all existing execution contexts (lambda instances) are busy. There is basically nothing you need to do here, except maybe set the maximum allowed concurrency if you want to throttle.
As a result of that, there is no integration with AutoScaling, but you can still use an Application Load Balancer to trigger your Lambda Function if that's what you're after.
If you're building a purely serverless application, you might want to look into the API Gateway instead of the ALB integration.
Update
Since you've clarified what you want to use auto scaling for, namely changing the provisioned concurrency of the function, there are ways to build something like that. Clément Duveau has mentioned a solution in the comments that I can get behind.
You can create a Lambda Function with two CloudWatch events triggers with Cron-Expressions. One for when you want to scale out and another one for when you want to scale in.
Inside the lambda function you can use the name of the rule that triggered the function to determine if you need to do a scale out or scale in. You can then use the PutFunctionConcurrency API-call through one of the SDKs mentioned at the bottom of the documentation to adjust the concurrency as you see fit.
Update 2
spmdc has mentioned an interesting blog post using application auto scaling to achieve this, I had missed that one - you might want to check it out, looks promising.
The proper way to scale AWS Lambda provisioned concurrency is by using Application Auto Scaling.
At the time of writing, you cannot do so through the AWS console, but you can use AWS CLI by passing the --schedule flag as follows:
aws application-autoscaling register-scalable-target \
--service-namespace lambda \
--scalable-dimension lambda:function:ProvisionedConcurrency \
--resource-id function:my-function:BLUE \
--min-capacity 0 \
--max-capacity 100
If you want to scale up only during peak hours, you can run the following:
aws application-autoscaling put-scheduled-action --service-namespace lambda \
--scalable-dimension lambda:function:ProvisionedConcurrency \
--resource-id function:CreateOrder:prod \
--scheduled-action-name scale-out \
--schedule "cron(45 11 * * ? *)" \
--scalable-target-action MinCapacity=250
More details from the official AWS blog post.