-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
[Lambda DevX] Bypass Concurrency Settings #11418
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
Conversation
S3 Image Test Results (AMD64 / ARM64) 2 files 2 suites 3m 28s ⏱️ Results for commit 58e684b. |
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.
Seems like a sensible addition, LGTM!
@@ -125,6 +128,24 @@ def get_invocation_lease( | |||
unqualified_function_arn = function_version.id.unqualified_arn() | |||
qualified_arn = function_version.id.qualified_arn() | |||
|
|||
# Enforce one lease per ARN if the global flag is set |
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.
What global flag should be set?
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.
The LDM flag and in the LDM config we have settings for this qualified arn, hence the if is_lambda_debug_enabled_for(qualified_arn)
Motivation
Lambda Debug Mode configurations allow users to specify a debug port for each qualified Lambda ARN. This means that as long as lease limits are not exceeded, the system can concurrently evaluate multiple invocations of the same Lambda function version. However, this also means that additional containers might attempt to establish new debugging sessions on the same port. A similar issue can arise when updating provisioned concurrency configurations, which can result in multiple containers being spun up for the same Lambda function version. To enhance the developer experience in debugging Lambda functions, these changes introduces bypass logics for leasing and provisioning multiple instances of the same Lambda function version when it is being debugged.
Changes
is_lambda_debug_enabled_for
which computed whether the given lambda arn is being debuggedlocalstack.services.lambda_.invocation.counting_service.CountingService.get_invocation_lease
1
environment inlocalstack.services.lambda_.invocation.assignment.AssignmentService.scale_provisioned_concurrency
Testing
As a testing setup for Lambda Debug Mode is in the works and this feature is in preview, testing is conducted manually. Here follow scenarios relevant for these changes.
Test for Concurrent Invocations
Start Lambda Debug Mode with config:
deploy lambda functions
handler_1-handler_1
:Send a first invoke for
handler_1-handler_1
Send a second invoke (on another thread) for
handler_1-handler_1
Assert that in the console the warning message
Concurrent lambda invocations disabled for 'arn:aws:lambda:eu-central-1:000000000000:function:handler_1-handler_1:$LATEST' by Lambda Debug Mode
for the second invocation, whilst the first one can continue to be debugged as usual by connecting to 19891Assert only one container for the lambda version was created
If the tool used to forward the invocation requests implements a periodic retry (such as boto) then the above error message would show up every time the request is received
Test for Provisioning
Start Lambda Debug Mode with config (note we are defining the qualifier for version
1
in this configuration, that means thatarn:aws:lambda:eu-central-1:000000000000:function:handler_1-handler_1
, which is equal toarn:aws:lambda:eu-central-1:000000000000:function:handler_1-handler_1$LATEST
will not be affected by Lambda Debug Mode in any way):deploy lambda functions
handler_1-handler_1
:create a version for the lambda function:
awslocal lambda publish-version --function-name handler_1-handler_1
request provisioning for more than one instance:
assert in the console the following warning is logged:
Environments for 'arn:aws:lambda:eu-central-1:000000000000:function:handler_1-handler_1:1' enforced to '1' by Lambda Debug Mode, configurations will continue to report the set value '30'
assert only one container for the lambda version is created
Send a first invoke for
handler_1-handler_1:1
Send a second invoke (on another thread) for
handler_1-handler_1:1
Assert only one container for the lambda version was created
Assert that in the console the warning message
Concurrent lambda invocations disabled for 'arn:aws:lambda:eu-central-1:000000000000:function:handler_1-handler_1:1' by Lambda Debug Mode
for the second invocation, whilst the first one can continue to be debugged as usual by connecting to 19891