Resque 和多服务器架构

Resque and a multi-server architecture

我还没有真正使用过Resque。我有以下问题和假设需要验证:

1) 我知道您可以通过将每个 resque 实例配置为指向中央 redis 服务器来拥有多服务器架构。正确吗?

2) 这是否意味着任何 resque 实例都可以将项目添加到队列并且任何工作人员都可以在任何这些队列上工作?

3) 多个工作人员可以响应队列中的同一项目吗? IE。一台服务器将 "item 2 has been updated" 放入队列中,不同服务器上的工作人员 1、2 和 3 是否都可以对此进行操作?或者我需要创建单独的队列吗?我有点想要 pub/sub 类型的任务。

4) Sinatra 监视器应用程序是否存在于每个 Resque 实例上?还是只有一个应用程序知道所有队列和工作人员?

5) Resque 知道任务何时完成吗? IE。监控应用程序是否显示任务正在进行中?或者只是一个工人拿走了它?

6) 监控应用程序是否显示已完成的任务? IE。如果一项任务很快完成,我是否能够在最近的某个时间点看到该任务已经完成?

7) 我能否以编程方式查询任务是否已开始、正在进行或已完成?

由于我在我们的项目中广泛使用 resque,这里有几个问题的答案:

I understand that you can have a multi-server architecture by configuring each of your resque instances to point to a central redis server. Correct?

回答:是的,您有多个服务器指向单个 resque 服务器。我运行在类似的架构上。

Does this mean that any resque instance can add items to a queue and any workers can work on any of those queues?

Ans:这取决于您如何配置服务器,您必须创建队列并为它们分配工作人员。 您可以有多个队列,每个队列可以有多个工作人员处理它们。

Can multiple workers respond to the same item in a queue? I.e. one server puts "item 2 has been updated" in a queue, can workers 1, 2, and 3, on different servers, all act on that? Or would I need to create separate queues? I kind of want a pub/sub types tasks.

回答:这也是根据您的要求,如果您希望有一个队列并且所有工作人员都在处理它,这也是有效的。
或者如果你想为每个服务器单独排队,你也可以这样做。
任何服务器都可以将作业放入任何队列,但只有指定的工作人员会接手并处理该作业

Does the Sinatra monitor app live on each instance of Resque? Or is there just one app that knows about all the queues and workers?

回答:Sinatra 监视器应用程序为您提供了一个界面,您可以在其中查看所有 workers/queues 相关信息,例如 运行 作业、等待作业、队列和失败作业等。

Does Resque know when a task is completed? I.e. does the monitor app show that a task is in process? Or just that a worker took it? Ans: It does, basically resque also maintains internal queues to manage all the jobs.

回答:是的,它显示了有关工作的所有统计数据。

Does the monitor app show completed tasks? I.e. if a task complete quickly will I be able to see that at some point in the recent past that task was completed?

回答:是的,你可以做到
例如,要知道哪些工人在工作,请使用 Resque.working,同样,您可以检查他们的代码库并使用任何东西。


Resque 是一个非常强大的库,我们已经使用了一年多了。
干杯快乐编码!