16

在 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

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

什么是一个实际的例子,说明为什么在一个主机上让多个工作人员处理同一个队列会很好,就像上面的例子一样?这不是设置并发的目的吗?

更具体地说,以下两行(A和B)之间是否有任何实际区别?:

A:

$ celeryd-multi start 10 -c 2 -Q data

乙:

$ celeryd-multi start 1 -c 20 -Q data

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

谢谢!

4

1 回答 1

8

什么是一个实际的例子,说明为什么在一个主机上让多个工作人员处理同一个队列会很好,就像上面的例子一样?

答:</p>

因此,如果出现以下情况,您可能希望在同一机器节点上运行多个工作程序实例:

  • 您正在使用多处理池并希望并行使用消息。一些报告使用多个工作程序实例而不是运行具有多个池工作程序的单个实例具有更好的性能。

  • 您正在使用 eventlet/gevent(并且由于臭名昭著的 GIL,也是“线程”)池),并且您希望在多个 CPU 内核上执行任务。

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

于 2014-05-20T15:44:58.320 回答