Can I use a Celery Group primitive as the umbrella task in a map/reduce workflow?
Or more specific: Can the subtasks in a Group be run on multiple workers on multiple servers?
From the docs:
However, if you call apply_async on the group it will send a special
grouping task, so that the action of calling the tasks happens in a worker
instead of the current process
That seems to imply the tasks are all send to one worker…
Before 3.0 (and still) one could fire off the subtasks in a TaskSet which would run on multiple servers. The problem is determining whether all tasks have finished executing. That is normally done by polling all subtasks which is not really elegant.
I am wondering if the Group primitive can be used to mitigate this problem.
I found out it is possible to use Chords for such a map reduce like problem.
When the mapper is executed on a cluster of three workers/servers it first executes the mapper which splits your problem and the creates new subtasks that are again submitted to the broker. These run in parallel because the queue is consumed by all brokers. Also an chord task is created that polls all maps to see if they have finished. When done the reduce task is executed where you can glue your results back together.
In all: yes it is possible. Thanks for the vegetable guys!