[英]Laravel 4: Queues and Multiple Listeners
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? 如果我在具有Laravel 4应用程序的服务器上运行带有Supervisor的Beanstalk,并且我希望它以异步方式处理所有队列 - 尽可能多次同时处理 - 我可以同时运行多个侦听器吗? 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
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. IMO最好将Supervisor配置为运行多个
queue:work
命令。 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). 不鼓励在无限循环中运行PHP脚本(如
queue:listen
),因为一段时间后它们可能会出现内存问题(泄漏等)。
You can configure Supervisor to re-run finished workers. 您可以将Supervisor配置为重新运行已完成的工作人员。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.