resquebundle / resque

ResqueBundle for Symfony 4+
MIT License
50 stars 29 forks source link

[INFORMATION] Am I defining a serial behaviour when using `Changing the queue` feature? #57

Closed rogeraraujo90 closed 4 years ago

rogeraraujo90 commented 4 years ago

I have two Jobs in my project that need run in a specific order. I want to know if I use the same queue name using the feature explained here: https://github.com/resquebundle/resque#more-features If can I trust that these Jobs will run in a serie.

If this is not the correct place to make questions, sorry about that. I can't find a better place.

PhilETaylor commented 4 years ago

No. If you queue jobs on the same queue name, and you have more than 1 worker process running, then the workers will take those jobs from the queue as quick as possible and process them independently of the other jobs, in parallel and not in series. Thats the whole point of a job queue.

You could:

rogeraraujo90 commented 4 years ago

Thank you for the response. I'll close this issue.

My team decided start a new worker that is responsible for watch one queue only (we still have five workers in parallel watching the default queue). Since we have just one worker we can have a serial behaviour right?

Are you seeing some problem with this approach?

PhilETaylor commented 4 years ago

Ive not checked the code, but your logic assumes that the jobs are served from the oldest to the newest... that might be a good assumption, but it might be worth checking how the code pulls a job from the queue...

PhilETaylor commented 4 years ago

A quick look at rescue/php-resque and it says it uses Redis lpop to get the job from the queue https://redis.io/commands/lpop - so this is an oldest out strategy and what you want (rather than some other random strategy)