1

When using kue in an app that has multiple instances (say multiple containers in docker) that all use the same redis database, if you pause a worker, do you need to pause that worker on all instances or is that handled at the redis level and hence handled for you?

https://github.com/Automattic/kue#pause-processing

queue.process('email', function(job, ctx, done){
  ctx.pause( 5000, function(err){
    console.log("Worker is paused... ");
    setTimeout( function(){ ctx.resume(); }, 10000 );
  });
});

It'd be great if we didn't have to use any instance-to-instance communication to get all workers to pause.

CTC
  • 451
  • 1
  • 8
  • 20

1 Answers1

0

From reading through the code, it appears that pausing a worker simply cleans up the redis client for that worker and stops listening for events from redis.

Here is the relevant code. https://github.com/Automattic/kue/blob/master/lib/queue/worker.js#L288-L302

So there is nothing that would prevent another instance of the same application from continuing to process messages. Therefore, if you have multiple instances of the same application running, and you want to pause a worker, you must signal to every instance of the application that a pause event has occurred.

We're using the pubsub functionality in redis to signal to all workers that they should pause/resume.

CTC
  • 451
  • 1
  • 8
  • 20