Home > database >  Check if Lambda function is available boto3
Check if Lambda function is available boto3

Time:01-14

I have a lambda function that I'm calling using boto3. There is a high chance that there will be many concurrent executions and I know that Lambda throttles you if you make too many requests. I am doing this in an synchronous manner, so there are no retries. I want to make sure I know when this will happen, so that I can push requests onto a queue, and try them again at a later time.

Boto3 will return an error if there are too many requests, but I would rather not use try and catch for this. From the boto3 docs:

For example, Lambda returns TooManyRequestsException if executing the function would cause you to exceed a concurrency limit at either the account level (ConcurrentInvocationLimitExceeded ) or function level (ReservedFunctionConcurrentInvocationLimitExceeded ).

Does anyone know of a way to check if the function is available for execution before hand?

Thanks.

CodePudding user response:

Does anyone know of a way to check if the function is available for execution before hand?

No, there isn't a way unless you maintain a counter yourself, which would also be a rough estimate.

Use a try catch statement as this is where it is meant to be used at a code level, use asynchronous invocation or retry your synchronous invocation using exponential backoff (increasing the duration between retries every time).

  •  Tags:  
  • Related