How to move a beanstalkd job in the ready queue to the front if the queue is very big and is taking a while to process?

StackOverflow https://stackoverflow.com/questions/13408760

  •  29-11-2021
  •  | 
  •  

Question

I had a quick question in regards to a beanstalkd queue.

So say I have 500,000 ready jobs in the beanstalk queue which are just waiting be processed and at the same time more jobs are being added to this queue. All of these jobs have the same priority.

Is it possible to move a job in the ready queue so that it can be processed before all of the other jobs in that queue?

I've just started using beanstalk and I was wondering whether this is possible to do in beanstalk?

I'm on a linux environment.

I guess I could delete that specific job and reinsert it with a priority that will allow it to be processed first but I would like to avoid doing that yet unless there is a command that will allow me to do that.

Please let me know if more information is required and I thank you in advance for your help. :)

Was it helpful?

Solution

There is no such command currently in Beanstalkd.

This is what different priorities are used for.

OTHER TIPS

Beanstalk has a new command as of version 1.12: reserve-job.

A job can be reserved by its id. Once a job is reserved for the client, the client has limited time to run (TTR) the job before the job times out. When the job times out, the server will put the job back into the ready queue. The command looks like this:

reserve-job <id>\r\n

<id> is the job id to reserve

This should immediately return one of these responses:

NOT_FOUND\r\n if the job does not exist or reserved by a client or is not either ready, buried or delayed. RESERVED <id> <bytes>\r\n<data>\r\n. See the description for the reserve command.

Assuming you know the ID of the job that needs the priority adjustment, you can connect to beanstalk, reserve that specific job, then release it with a new priority:

release <id> <pri> <delay>

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top