在芹菜中,让多个工人处理同一个队列的目的是什么?

cha*_*imp 16 task-queue celery celery-task celeryd

在celeryd-multi的文档中,我们找到了这个例子:

# Advanced example starting 10 workers in the background:
#   * Three of the workers processes the images and video queue
#   * Two of the workers processes the data queue with loglevel DEBUG
#   * the rest processes the default' queue.
$ celeryd-multi start 10 -l INFO -Q:1-3 images,video -Q:4,5 data
    -Q default -L:4,5 DEBUG
Run Code Online (Sandbox Code Playgroud)

(从这里:http://docs.celeryproject.org/en/latest/reference/celery.bin.celeryd_multi.html#examples)

什么是一个实际的例子,说明为什么在一个主机上有多个工作程序处理相同的队列是好的,如上例所示?这不是设置并发性的原因吗?

更具体地说,以下两行(A和B)之间是否存在实际差异?:

A:

$ celeryd-multi start 10 -c 2 -Q data
Run Code Online (Sandbox Code Playgroud)

B:

$ celeryd-multi start 1 -c 20 -Q data
Run Code Online (Sandbox Code Playgroud)

我担心由于我不理解这种实际差异,我遗漏了一些关于任务队列的宝贵知识,如果有人能够启发我,我将不胜感激.

谢谢!

Tyl*_*ong 8

什么是一个实际的例子,说明为什么在一个主机上有多个工作程序处理相同的队列是好的,如上例所示?

回答:

因此,您可能希望在同一计算机节点上运行多个工作器实例,如果:

  • 您正在使用多处理池并希望并行使用消息.有些人使用多个工作器实例报告更好的性能,而不是使用许多池工作者运行单个实例.

  • 您正在使用eventlet/gevent(由于臭名昭着的GIL,也包括'threads')池,并且您希望在多个CPU核心上执行任务.

参考:http://www.quora.com/Celery-distributed-task-queue/What-is-the-difference-between-workers-and-processes