英文:
Supervisord configuration for Laravel
问题
I am using Supervisord to help keep my Laravel-based App queue running. And I am wondering if the below configuration is correct.
在我的 Laravel 应用中,我使用 Supervisord 来保持队列运行,我想知道下面的配置是否正确。
In Laravel docs, for example, numprocs
is set 8, which means that Supervisord will run queue:work 8 times, is and why this is a good thing?
在 Laravel 文档中,例如,numprocs
被设置为 8,这意味着 Supervisord 会运行 queue:work 8 次,这是否是一个好事,为什么?
Also, should I be using --daemon in the queue:work command?
另外,我是否应该在 queue:work 命令中使用 --daemon?
英文:
I am using Supervisord to help keep my Laravel-based App queue running. And I am wondering if the below configuration is correct.
In Laravel docs, for example, numprocs
is set 8, which means that Supervisord will run queue:work 8 times, is and why this is a good thing?
Also, should I be using --daemon in the queue:work command?
[program:app-queue]
process_name=%(program_name)s_%(process_num)02d
command=php /home/app/public_html/app/artisan queue:work --daemon --sleep=3 --tries=3
autostart=true
autorestart=true
user=root
startsecs=0
stopwaitsecs=60
redirect_stderr=true
stdout_logfile=/home/app/public_html/app/storage/logs/queue-out.log
答案1
得分: 2
numprocs
会生成8个进程,然后每3秒轮询队列。当设置了daemon
时,这些进程不会重新启动,除非有指令告知,这既有服务器负载的优势,也有在更新代码基础时可能出现的一些潜在边缘情况的劣势。
拥有8个进程意味着在运行作业时可能会有8倍的吞吐量。
示例:
有许多情况下,同时运行多个进程是有利的。
例如,假设您要处理1000个用户,并想检查每个用户在过去一个月内发表了多少评论。假设每次检查需要1分钟的处理时间(虽然这有点极端,但它能更好地说明问题),如果您通过循环遍历1000个用户的数组或集合来依次运行它们,那将需要1000分钟才能完成。这超过了16小时!
如果将它们排队为作业,并将numprocs
设置为16,那么您只需要稍微超过一个小时就可以完成!
英文:
numprocs
will spawn 8 processes that will then poll the queue every 3 seconds. When daemon
is set, these processes will not restart unless told to which has both advantages in terms of server load and disadvantages in the form of some potential edge cases when updating your code base.
Having 8 processes means that you have potentially 8 times the throughput when running jobs.
Example:
There are many scenarios where having multiple processes running in parallel are advantageous.
For instance, say you are processing 1000 users and want to check how many comments each has made in the last month. Say each check takes a minute to process (extreme but it makes a better point), it would take 1000 minutes to complete if you run then in sequence by looping through a array or collection of a 1000 users. That's over 16 hours!
If you queued these as jobs and have numprocs
set to 16, then you are done in just over and hour!
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论