Elastic Beanstalk 工作线程和 VisibilityTimeout 期限

Elastic Beanstalk Workers and the VisibilityTimeout period

根据http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features-managing-env-tiers.html

If the application returns any response other than 200 OK, then Elastic
Beanstalk waits to put the message back in the queue after the configured
VisibilityTimeout period.

我已将 VisibilityTimeout 设置为 1 分钟。我的应用程序在处理请求时返回 400 错误。我从日志中看到请求每 2 秒重试一次!基于以上,我期待它每 60 秒重试一次。

我错过了什么?

这可能根本不是 SQS 队列的问题。的确,消息仅在指定的 VisibilityTimeout 后才返回到队列中,但这取决于您如何轮询消息。

如果您不直接访问队列(而是使用某种服务为您做这件事),那么您还有另一层复杂性。

Elastic Beanstalk 中有一个名为 sqsd 的工作进程正在执行轮询(处理消息并在您响应 200 后将其从队列中删除)。

sqsd 使用类似的概念,称为 InactivityTimeout - 这指定了该工作人员等待 200 响应的时间,如果是这样,它会在该时间后重新发送消息响应未送达。

我的猜测是您的问题的原因在于此 InactivtyTimeout。

如果这不是原因,请尝试查看 SQS 的 WaitTimeSeconds 参数。这指定如果队列中有消息,则应立即返回对 SQS 的调用(否则,它会等待指定的时间)。

我在 EC2 实例中遇到了类似的问题,我指定了所有超时。最后 - 它是由 Tomcat 中的错误引起的 - 看到这个:https://forums.aws.amazon.com/thread.jspa?threadID=183473