Supervisord 配置 for Laravel

huangapple go评论67阅读模式
英文:

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!

huangapple
  • 本文由 发表于 2020年1月4日 00:05:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/59581681.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定