Open alecl opened 4 years ago
Was that with zappa update or zappa deploy?
It was on zappa update. I actually tried zappa deploy as well and it gave me an error that I have already deployed and don't I mean update so couldn't redeploy (that used to work on an older version)
Oh, sorry, now I understand your question. Yes, we don't have support for provisioning yet. I don't see a way it could work with versions unless it's defined on the zappa_settings or through an alias.
Yes, that's essentially the workaround put in the meantime in a post-deploy script.
An alias of LIVE
that's pointed to by the API Gateway and the provisioned concurrency is set on that.
Relevant parts of the script below (some variables here but you can get the idea)
It would be ideal if Zappa let us specify the alias to use and provisioned concurrency level. For non-prod we would update the alias immediately on deploy. For production it would make sense as a separate step after testing is done.
export deployedversion=$(aws lambda list-versions-by-function --function-name "$lambdaname" --query "to_number(Versions[-1].[Version][0])" --no-paginate)
echo "Resetting provisioned concurrency on alias LIVE"
aws lambda delete-provisioned-concurrency-config \
--function-name "$lambdaname" \
--qualifier LIVE
echo "Updating alias LIVE to $deployedversion"
aws lambda update-alias \
--function-name "$lambdaname" \
--function-version "$deployedversion" \
--name LIVE
echo "Setting provisioned concurrency to $provisionedconcurrency"
aws lambda put-provisioned-concurrency-config \
--function-name "$lambdaname" \
--qualifier LIVE \
--provisioned-concurrent-executions "$provisionedconcurrency"
Thank you, I had mistaken it as a bug report, hence my initial confusion. Makes sense to me.
@alecl for some reason, the command aws lambda list-versions-by-function --function-name "$lambdaname" --query "to_number(Versions[-1].[Version][0])" --no-paginate
yields something different when the parameter 'no-paginate' is added or removed. Is it actually required?
Latest version being 167
$ aws lambda list-versions-by-function --function-name "dev" --query "to_number(Versions[-1].[Version][0])" --no-paginate
87
$ aws lambda list-versions-by-function --function-name "dev" --query "to_number(Versions[-1].[Version][0])"
167
any plan for adding this feature? Laravel Vapor already supports Provisioned Concurrency option and I want to enable it with Zappa as well. Supporting "Provisioned Concurrency" should solve all pre-warming related issues which are still open.
I wrote a blog about adding provisioned concurrency to an AWS Lambda project on https://markgituma.medium.com/improving-aws-lambda-cold-start-times-using-provisioned-concurrency-803b090406c2?sk=544c01f8c5811b4f2897e78eeed0a661, it leverages @alecl solution.
Hope it's useful :)
First pass at a Zappa callback function to set the provisioned concurrency: https://gist.github.com/dpmccabe/1e935626e7efd759d55bd2f44ba07439
Context
Using zappa 0.5.0 "lambda_concurrency": 2 to set https://docs.aws.amazon.com/lambda/latest/dg/configuration-concurrency.html#configuration-concurrency-provisioned
Expected Behavior
was expecting Provisioned concurrency configurations in Lambda to be set to 2 for the version just uploaded
Actual Behavior
Provisioned concurrency configurations is unset and remains at 2 for my previous version
Your Environment