AWS Lambda dynamic concurrency limit based on if other lambdas are running

Viewed 349

The problem:

  • Lambda A - Makes 1 requests to third party API
  • Lambda B - Makes 10 requests to third party API

I want a limit of 15 requests to the third party API at once

Ideal scenario:

  • If Lambda B is running, 5 Lambda A can run concurrently.
  • If Lambda B is not running, 15 Lambda A can run concurrently.

From what I've read you can set the concurrency limit per function e.g. I could set the limit for Lambda B at 1, and the limit for lambda A at 5. A lot lower than the ideal scenario.

Is the ideal scenario possible with AWS lambdas?

1 Answers

As you're using the API Gateway you can make use of API Gateway Throttling on the stage.

By adding throttling here you can limit the number of concurrent requests across all attached Lambda functions to that single deployment.

Related