gpt4 book ai didi

Laravel 多个服务器与 AWS 队列一起使用

转载 作者:行者123 更新时间:2023-12-02 20:58:34 26 4
gpt4 key购买 nike

我有 Laravel 应用程序在两台服务器上运行(使用负载均衡器),我想知道如果我将作业放入 AWS SQS 队列并且两台服务器都订阅了该队列,会发生什么。

  • 该作业是否有可能被多次处理?
  • 有什么方法可以进行设置,以便将作业放入队列的同一服务器可以处理该作业(考虑文件上传首先将文件存储在磁盘中)。

任何有关此类设置的经验/提示/建议都值得赞赏。

最佳答案

Is there any chance that the job will be processed more than once?

是的,SQS仅保证至少一次交付。您应该构建应用程序以允许传递消息的多个副本。 http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/standard-queues.html#standard-queues-at-least-once-delivery

通常解决此问题的方法是拥有一个可以锁定消息的唯一标识符的服务。这样您就可以限制关键部分。

Is there any way to setup things so the same server that put the job in the queue handles the job (think file uploads where the file is stored in disk first).

根据 Laurence 的建议,您可以为每个实例拥有单独的队列。

关于Laravel 多个服务器与 AWS 队列一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42519455/

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