Skip to content

Conversation

dominikschubert
Copy link
Member

@dominikschubert dominikschubert commented Mar 15, 2023

Account limit config addresses #7074

Background

AWS Lambda concurrency main docs page: https://docs.aws.amazon.com/lambda/latest/dg/lambda-concurrency.html
image

Assumptions

  • Lambda quota apply at different levels
    • Typically "per AWS region" (e.g., Concurrent executions)

Implementation

  • We keep a counter per region and function by storing the unqualified function ARN in a dict, protected by locks.
  • The counter should only be updated for 'on-demand' invocation types because provisioned concurrency is always deduced immediately after adding a provisioned concurrency config.
  • We calculate get_available_fn_concurrency before allowing or denying every potential invocation

Open (will mostly come in later PRs

  • Check if there are any provisioned concurrency execution environments available before raising TooManyRequestsException. We generally want to favor provisioned execution environments over on-demand.
  • get_available_fn_concurrency for async invokes 🤔
  • Make account limit configurable and monkeypatch the account settings test (opt-in parity)

@dominikschubert dominikschubert temporarily deployed to localstack-ext-tests March 15, 2023 16:10 — with GitHub Actions Inactive
@dominikschubert dominikschubert temporarily deployed to localstack-ext-tests March 15, 2023 17:33 — with GitHub Actions Inactive
@github-actions
Copy link

github-actions bot commented Mar 15, 2023

LocalStack integration with Pro

       3 files  ±  0         3 suites  ±0   1h 35m 22s ⏱️ +15s
1 834 tests +  5  1 442 ✔️ +2  392 💤 +  3  0 ±0 
2 566 runs  +13  1 809 ✔️ +2  757 💤 +11  0 ±0 

Results for commit 93969a6. ± Comparison against base commit d28e4c3.

♻️ This comment has been updated with latest results.

@joe4dev joe4dev temporarily deployed to localstack-ext-tests March 16, 2023 14:14 — with GitHub Actions Inactive
@dominikschubert dominikschubert temporarily deployed to localstack-ext-tests March 16, 2023 16:11 — with GitHub Actions Inactive
@dominikschubert dominikschubert temporarily deployed to localstack-ext-tests March 16, 2023 16:32 — with GitHub Actions Inactive
@dominikschubert dominikschubert marked this pull request as ready for review March 16, 2023 16:52
@dominikschubert dominikschubert requested a review from dfangl as a code owner March 16, 2023 16:52
@coveralls
Copy link

coveralls commented Mar 16, 2023

Coverage Status

Coverage: 85.183% (+0.06%) from 85.123% when pulling 93969a6 on lambda-concurrency into d28e4c3 on master.

Copy link
Member

@dfangl dfangl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM in general, just some things still unclear / missing TODO implementations.

@dominikschubert dominikschubert temporarily deployed to localstack-ext-tests March 20, 2023 12:47 — with GitHub Actions Inactive
@dominikschubert dominikschubert temporarily deployed to localstack-ext-tests March 20, 2023 12:53 — with GitHub Actions Inactive
@dominikschubert dominikschubert requested a review from thrau as a code owner March 20, 2023 14:00
@dominikschubert dominikschubert temporarily deployed to localstack-ext-tests March 20, 2023 14:00 — with GitHub Actions Inactive
@dominikschubert dominikschubert requested a review from dfangl March 20, 2023 14:02
@dominikschubert dominikschubert temporarily deployed to localstack-ext-tests March 20, 2023 14:03 — with GitHub Actions Inactive
@dominikschubert dominikschubert temporarily deployed to localstack-ext-tests March 21, 2023 08:40 — with GitHub Actions Inactive
Copy link
Member

@dfangl dfangl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, big changes and challenging feature :)
One test is still red, but no need to re-review once this is fixed (I think).

Comment on lines +313 to +318
if (
self.lambda_service.get_available_fn_concurrency(
self.function.latest().id.unqualified_arn()
)
> 0
):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we reduce the reserved concurrency and enough environments are already active, more than the "reserved" values can be run at the same time.
Nothing to hold back the merge, but we need to tackle it at some point.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah a lot of these edge cases should be tackled in a small cleanup project soon where we refactor the invocation loop & environment assignment.

Feel free to add tests for any edge cases you can think of for these cases. It'll definitely make this a lot easier for us afterwards to design the proper abstractions.We can collect these tests in a separate test class and skip it altogether for now. (not in the scope of the PR though)

Copy link
Member

@joe4dev joe4dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good first iteration to support the lambda concurrency features 👍

✅ The 4 tests tests.integration.awslambda.test_lambda.TestLambdaConcurrency pass on macOS

Follow-up PRs will need to cover several edge cases. Ideally, we would introduce appropriate abstractions to tackle the rising complexity of the version manager.

@dominikschubert dominikschubert temporarily deployed to localstack-ext-tests March 21, 2023 13:03 — with GitHub Actions Inactive
@dominikschubert dominikschubert temporarily deployed to localstack-ext-tests March 21, 2023 14:03 — with GitHub Actions Inactive
@dominikschubert dominikschubert merged commit aeb3000 into master Mar 21, 2023
@dominikschubert dominikschubert deleted the lambda-concurrency branch March 21, 2023 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants