Old question, but still add my answer if it helps someone. My understanding from the initial testing was the same as in David Wolever’s answer. I just experienced this more in celery 3.1.19 and -Ofair really works. It’s just not intended to disable prefetching at the working node level. This will continue. Using -Ofair has a different effect, which is at the pool level. So, to completely disable prefetching, do this -
- Set
CELERYD_PREFETCH_MULTIPLIER = 1 - Set
CELERY_ACKS_LATE = True at global or task level - Use
-Ofair when starting workers - If you set concurrency to 1, then step 3 is not needed. If you want higher concurrency, then step 3 is necessary to avoid backing up to a node that can run with running tasks.
Adding additional information:
I found that a working node will always be the prefect by default. You can control only the number of jobs that it prefix using CELERYD_PREFETCH_MULTIPLIER . If set to 1, it will only precede as many tasks as the number of concurrency pools in a node. Therefore, if you have concurrency = n, the maximum tasks pre-programmed by node will be n.
Without the -Ofair option, it -Ofair to me that if one of the pool workflows was performing a multi-year task, other workers in node also stopped processing tasks already programmed with node. Using -Ofair , this has changed. Although one of the workers in node performed lengthy tasks, others did not stop processing and continued to process tasks previously programmed by node. Therefore, I see two levels of prefetching. One at the working node level. The other is at the individual worker level. Using -Ofair for me seemed to disable it at the working level.
How is ACKS_LATE related? ACKS_LATE = True means that the task will be confirmed only when the task is completed successfully. If not, I believe this will happen when it is received by the employee. In the case of prefetching, the task first gets the worker (confirmed from the logs), but will be completed later . I only realized that messages previously written to memory appear under unrecognized messages in rabbitmq. So I'm not sure that setting True to True is absolutely necessary. In any case, our tasks were set in this way (in the last) for other reasons.
ksrini Jun 08 '16 at 10:30 2016-06-08 10:30
source share