简体   繁体   English

Laravel 的主管配置

[英]Supervisord configuration for Laravel

I am using Supervisord to help keep my Laravel-based App queue running.我正在使用 Supervisord 来帮助保持我的基于 Laravel 的应用程序队列运行。 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?例如,在 Laravel 文档中, numprocs设置为 8,这意味着 Supervisord 将运行 queue:work 8 次,为什么这是一件好事?

Also, should I be using --daemon in the queue:work command?另外,我应该在 queue:work 命令中使用 --daemon 吗?

[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

numprocs will spawn 8 processes that will then poll the queue every 3 seconds. numprocs将产生 8 个进程,然后每 3 秒轮询一次队列。 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.设置daemon ,这些进程将不会重新启动,除非在更新代码库时被告知在服务器负载方面具有优势和在某些潜在边缘情况下的劣势。

Having 8 processes means that you have potentially 8 times the throughput when running jobs.拥有 8 个进程意味着您在运行作业时可能拥有 8 倍的吞吐量。


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.例如,假设您正在处理 1000 个用户,并且想要查看每个用户在上个月发表的评论数量。 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.假设每个检查需要一分钟来处理(极端但它说明更好),如果您通过循环遍历数组或 1000 个用户的集合按顺序运行,则需要 1000 分钟才能完成。 That's over 16 hours!超过16个小时!

If you queued these as jobs and have numprocs set to 16, then you are done in just over and hour!如果您将这些作为作业排入队列并将numprocs设置为 16,那么您只需一个多小时就完成了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM