Search code examples
amazon-web-servicesaws-lambdaaws-fargateaws-sdk-go

Getting ThrottlingException: Rate exceeded, status code: 400 on AWS API


I have 110 Fargate tasks running (not always in parallel). I am trying to get lambdas from other AWS accounts (through CrossAccountRole) using "ListFunctions" call as guided on the AWS SDK - https://docs.aws.amazon.com/sdk-for-go/api/service/lambda/#Lambda.ListFunctions

I sometimes get a Throttling error, while making the (SDK) API call: ThrottlingException: Rate exceeded, status code: 400

Also have gone through this solution - https://docs.aws.amazon.com/general/latest/gr/api-retries.html

Wanted to understand whether the AWS SDK Service (lambda) already implements it. Do I need a custom implementation of retries in my case or just increase the rate limit of Fargate?


Solution

  • For the docs you posted:

    In addition to simple retries, each AWS SDK implements exponential backoff algorithm for better flow control.

    This is further clarified in the aws blog:

    Note: Each AWS SDK implements automatic retry logic and exponential backoff algorithms.

    Do I need a custom implementation of retries in my case or just increase the rate limit of Fargate?

    If you use AWS SDK, you don't have to implement anything special. However, you your exception can be related to AWS Lambda function scaling:

    When requests come in faster than your function can scale, or when your function is at maximum concurrency, additional requests fail with a throttling error (429 status code).

    Thus if you think that you are hitting your concurrency limits on lambda, which could be due to large number of Fargate tasks, you can consider asking the AWS support for its increase. Default limit is 1000, which seems to be sufficient for your tasks. But maybe the other account is also running other lambdas. The 1000 limit is for all functions in an account and region.