Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 4: Queues and Multiple Listeners

Tags:

php

laravel

If I am running Beanstalk with Supervisor on a server with a Laravel 4 application, and I want it to process all queues asynchronously -- as many as it can at the same time -- can I have multiple listeners running at the same time? Will they be smart enough to not "take" the same to-do item from the queue, or will they all reach for the same one at the same time, and thus not work in the way I'm wanting? In short, I want to use Queues to process multiple tasks at a time -- can this be done?

php artisan queue:listen && php artisan queue:listen && php artisan queue:listen
like image 400
swt83 Avatar asked Dec 30 '13 05:12

swt83


1 Answers

In short, I want to use Queues to process multiple tasks at a time -- can this be done?

In short - yes it can be done. Every job taken by a worker is locked until it's release. It means that other workers will get different jobs to process.

IMO it's better to configure Supervisor to run multiple queue:work command. It will take only one job, process it and stop execution. It's not encouraged to run PHP scripts in a infinite loop (as queue:listen does), because after some time they can have memory issues (leaks etc).

You can configure Supervisor to re-run finished workers.

like image 114
radmen Avatar answered Oct 07 '22 20:10

radmen