获取 ThrottlingException:超出速率,状态代码:AWS 上的 400 API

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

我有 110 个 Fargate 任务 运行(并不总是并行的)。我正尝试按照 AWS SDK 上的指导使用“ListFunctions”调用从其他 AWS 账户(通过 CrossAccountRole)获取 lambda - https://docs.aws.amazon.com/sdk-for-go/api/service/lambda/#Lambda.ListFunctions

我在进行 (SDK) API 调用时有时会遇到节流错误: ThrottlingException:超出速率,状态代码:400

也经历过这个解决方案 - https://docs.aws.amazon.com/general/latest/gr/api-retries.html

想了解 AWS SDK 服务 (lambda) 是否已经实现了它。在我的案例中,我是否需要自定义实现重试或只是增加 Fargate 的速率限制?

对于您发布的文档:

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

这在 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?

如果您使用 AWS SDK,则无需实施任何特殊操作。但是,您的异常可能与 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).

因此,如果您认为您在 lambda 上达到了并发限制,这可能是由于大量的 Fargate 任务,您可以考虑要求 AWS 支持增加它.默认限制为 1000,这似乎足以完成您的任务。但也许其他帐户也是 运行 其他 lambda。 1000 个限制适用于帐户和区域中的所有函数