Search code examples
resque

Resque and a multi-server architecture


I haven't yet actually used Resque. I have the following questions and assumptions that I'd like verified:

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

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

3) 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.

4) 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?

5) 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?

6) 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?

7) Can I programmatically query whether a task has been started, is in progress, or is completed?


Solution

  • As I am using resque extensively in our project, here are few answers for your query:

    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?

    Ans: Yes you have multiple servers pointing to single resque server. I am running on similar architecture.

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

    Ans: This depends on how you are configuring your servers, you have to create queues and them assign workers to them. You can have multiple queues and each queue can have multiple workers working on them.

    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.

    Ans: This again based on your requirement, if you want to have a single queue and all workers working on it, this is also valid.
    or if you want separate queue for each server you can do that also.
    Any server can put jobs in any queue but only assigned workers will pickup and work on that job

    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?

    Ans: Sinatra monitor app gives you an interface where you can see all workers/queues related info such as running jobs, waiting jobs, queues and failed jobs etc.

    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.

    Ans: Yes it shows every stats about the Job.

    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?

    Ans: Yes you can do
    for example to know which workers are working use Resque.working, similarly you can check their code base and utilise anything.


    Resque is a very powerful library we are using for more than one year now.
    Cheers happy coding!!