gpt4 book ai didi

amazon-web-services - 限制 lambda 时,AWS Lambda + API-gateway 返回 502 错误

转载 作者:行者123 更新时间:2023-12-04 08:16:27 24 4
gpt4 key购买 nike

Synchronous invocation: If the function is invoked synchronously andis throttled, Lambda returns a 429 error and the invoking service isresponsible for retries. The ThrottledReason error code explainswhether you ran into a function level throttle (if specified) or anaccount level throttle (see note below). Each service may have its ownretry policy. For example, CloudWatch Logs retries the failed batch upto five times with delays between retries. For a list of event sourcesand their invocation type, see Supported Event Sources.

Reference

我不确定我对上面这句话的理解是否正确,如果我错了,请纠正我。

  1. 当 lambda 被限制时,它会向 API 网关返回 429 错误
  2. 调用服务(此处为 API 网关)重试请求。

但是,它没有按预期工作。以下是限制 lambda 时来自 cloudWatch 的 API 网关日志。

API-Gateway-Execution-Logs_3f1frvtwe4/sam-sm-test 2a38a4a9316c49e5a833517c45d31070 (bededbf0-73ae-11e8-87a2-f51933ef104f) Endpoint response body before transformations: {"Reason":"ReservedFunctionConcurrentInvocationLimitExceeded","Type":"User","message":"Rate Exceeded."}
API-Gateway-Execution-Logs_3f1frvtwe4/sam-sm-test 2a38a4a9316c49e5a833517c45d31070 (bededbf0-73ae-11e8-87a2-f51933ef104f) Endpoint response headers: {Connection=keep-alive, x-amzn-RequestId=bedfc624-73ae-11e8-bd28-6345cb3606c4, x-amzn-ErrorType=TooManyRequestsException, Content-Length=104, Date=Tue, 19 Jun 2018 10:51:39 GMT, Content-Type=application/json}
API-Gateway-Execution-Logs_3f1frvtwe4/sam-sm-test 2a38a4a9316c49e5a833517c45d31070 (bededbf0-73ae-11e8-87a2-f51933ef104f) Execution failed due to configuration error: Malformed Lambda proxy response

实际上,Lambda 返回 {"Reason":"ReservedFunctionConcurrentInvocationLimitExceeded","Type":"User","message":"Rate Exceeded."} 这是 API 网关的错误格式(代理集成)然后,API 网关返回 502 Error 给调用 API 的客户端。

我希望重试失败的请求。我该怎么办?

最佳答案

Each service may have its own retry policy.

API Gateway 不会重试失败的 Lambda 调用。如果要处理重试,则必须在调用 API 网关的客户端中完成。

按照您的建议,API 网关在收到格式错误的 Lambda 代理响应时返回 502 错误(请参阅 https://aws.amazon.com/premiumsupport/knowledge-center/malformed-502-api-gateway/)。

关于amazon-web-services - 限制 lambda 时,AWS Lambda + API-gateway 返回 502 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50929878/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com