gpt4 book ai didi

amazon-web-services - AWS SQS 长轮询不会减少空接收

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

目前,我有一个 AWS SQS 作为我的 AWS Lambda 函数的触发器。

我想实现长轮询以降低成本,因为我已经用完了每月免费套餐的 70%,主要来自空接收。

我尝试通过更改队列属性 ReceiveMessageWaitTimeSeconds 来设置长轮询至 20 seconds :

SQS Details showing ReceiveMessageWaitTimeSeconds set to 20s

但是,这似乎并没有减少空接收的数量,其中设置在 2019 年 11 月 2:00 - 3:00 之间发生了更改。
Empty Receives graph shows the same trend even after setting long polling

根据AWS Documentation , WaitTimeSeconds优先于队列属性 ReceiveMessageWaitTimeSeconds

Short polling occurs when the WaitTimeSeconds parameter of a ReceiveMessage request is set to 0 in one of two ways:

  • The ReceiveMessage call sets WaitTimeSeconds to 0.
  • The ReceiveMessage call doesn’t set WaitTimeSeconds, but the queue attribute ReceiveMessageWaitTimeSeconds is set to 0.

Note

For the WaitTimeSeconds parameter of the ReceiveMessage action, a value set between 1 and 20 has priority over any value set for the queue attribute ReceiveMessageWaitTimeSeconds.



由于 AWS Lambda 正在接收 SQS 请求,我不认为 WaitTimeSeconds可以配置。

为什么我的长轮询配置在这种情况下不起作用?是我误解了什么,还是我配置错了?

谢谢!

最佳答案

实际上,长轮询在您的情况下有效。
5 lambdas * polling / 20 seconds * 3600 seconds in an hour = 900 receives/hour
我认为您错过的是“5 个最小并发 lambda”。这暗示在 Lambda Scaling Behaviour 中文档,但在 announcement/deep-dive blog 的“附加信息”部分中提供了更有帮助和明确的说明。 .

When an SQS event source mapping is initially created and enabled, or when messages first appear after a period with no traffic, then the Lambda service will begin polling the SQS queue using five parallel long-polling connections. The Lambda service monitors the number of inflight messages, and when it detects that this number is trending up, it will increase the polling frequency by 20 ReceiveMessage requests per minute and the function concurrency by 60 calls per minute.

关于amazon-web-services - AWS SQS 长轮询不会减少空接收,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53372107/

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