Skip to content
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

Lambda is rate limited by AWS parameter store #59

Open
ChrisWoodUCAS opened this issue Nov 9, 2023 · 3 comments
Open

Lambda is rate limited by AWS parameter store #59

ChrisWoodUCAS opened this issue Nov 9, 2023 · 3 comments
Labels
feature-request A feature should be added or improved. module/sys-mgr-ext p2 This is a standard priority issue queued

Comments

@ChrisWoodUCAS
Copy link

Describe the bug

Our UI application is served up using a .NET Application hosted behind a lambda via API Gateway. This lambda also provides a secure route to our APIs. This lambda uses this package for cookie authentication. Unfortunately the current method PersistKeysToAWSSystemsManager only allows 40 requests per second and this does not scale to meet our needs on our key business day when we need in the region of 300 requests per second.

We need an alternative store for data verification that will solve this problem?

Expected Behavior

That we would be able to create 300 new lambdas every second to meet our concurrency needs

Current Behavior

We are only able to create 40 lambdas per second and are unable to get the desired throughput

Reproduction Steps

In Startup.cs we have the following code

        `services.AddRazorPages();
        services.AddCors();
        services.AddAntiforgery(options => { options.HeaderName = Constants.AntiforgeryHeaderName; });

        if (_config["ASPNETCORE_ENVIRONMENT"] == "Development")
        {
            services.AddDataProtection().PersistKeysToFileSystem(new DirectoryInfo(@"DataProtection"));
        }
        else
        {
            services.AddDataProtection().PersistKeysToAWSSystemsManager($"{_config["DeployedEnvironment:Name"]}/MyApplication/DataProtection");
        }`

This code is then deployed to a lambda that is exposed via API Gateway. When we make 1000 requests per second the lambdas fail to create due to rate limiting in the parameter store.

Possible Solution

Offer an alternative method to PersistKeysToAWSSystemsManager. Perhaps the keys could be persisted to S3 which has a greater allowed throughput.

Additional Information/Context

No response

AWS .NET SDK and/or Package version used

Targeted .NET Platform

.NET 6

Operating System and version

Windows 10

@ChrisWoodUCAS ChrisWoodUCAS added bug Something isn't working needs-triage This issue or PR still needs to be triaged. labels Nov 9, 2023
@ashishdhingra ashishdhingra added module/sys-mgr-ext needs-review queued feature-request A feature should be added or improved. p1 This is a high priority issue and removed needs-triage This issue or PR still needs to be triaged. bug Something isn't working labels Nov 9, 2023
@normj
Copy link
Member

normj commented Nov 10, 2023

Have you tried turning on SSM parameter store's higher throughput setting? https://docs.aws.amazon.com/systems-manager/latest/userguide/parameter-store-throughput.html. It takes you out of the free tier but does provide a higher throughput. Based on the numbers you estimated I'm not sure it will meet your requirements but worth measuring.

We used SSM parameter store over S3 because the API the Data Protection framework has for providers is basically a single call to go and get all protection keys. https://github.com/aws/aws-ssm-data-protection-provider-for-aspnet/blob/master/src/Amazon.AspNetCore.DataProtection.SSM/SSMXmlRepository.cs#L85

The problem with using S3 is there isn't a bulk way of getting a bunch of objects with unknown keys. For S3 I would need to make a list object call and then individual get object calls for each data protection key. Imagine when you start getting quite a few data protection keys how that would affect your Lambda function's cold start.

We could provide an alternative storage solution using DynamoDB, there we could do a query to get the list of keys for an "application" in the table. How would you feel about using DynamoDB as a storage solution?

@ashishdhingra ashishdhingra added p2 This is a standard priority issue and removed needs-review p1 This is a high priority issue labels Nov 10, 2023
@ChrisWoodUCAS
Copy link
Author

ChrisWoodUCAS commented Nov 13, 2023 via email

@duncanbrown
Copy link

Would the newly-announced batch api make Secrets Manager a viable alternative as a backing store?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved. module/sys-mgr-ext p2 This is a standard priority issue queued
Projects
None yet
Development

No branches or pull requests

4 participants