You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"You can disable this prefetching behavior by enabling the -Ofair worker option:
$ celery -A proj worker -l info -Ofair
With this option enabled the worker will only write to workers that are available for work, disabling the prefetch behavior."
but when I use that option I still get tasks pre-fetched to my workers, the prefetching problem that can occur with tasks that can take a long time to run as described in that section of the documentation is still plaguing me.
Is there really no way to disable prefetching entirely?
You're probably mistaking the pool child process pipe buffer with the broker prefetch limits. Disabling the latter would mean the worker slurps in as many messages as it can without limit.
My workers have a single process, and can only safely do one task at a time. That task can take anywhere from 2 minutes to three hours. Is ACKS_LATE my only option for preventing a short task from being stuck behind a long task?
Yes, the worker is "subscribing to messages" not polling. You would have to move to using the synchronous amqp method basic.get to get a different behavior, but that would also mean you would have to sacrifice response time (or go into a very fast polling loop)
I've run some experiments, and at least with Celery 3.1.15 and the Redis broker, neither -Ofair nor CELERYD_PREFETCH_MULTIPLIER = 1 disable prefetching.
To demonstrate this:
Set CELERYD_PREFETCH_MULTIPLIER = 1
Queue up 5 tasks that will each take a few seconds (ex, time.sleep(5))
Start watching the length of the task queue in Redis: watch redis-cli -c llen default
Start celery worker -c 1 -Ofair
Notice that the queue length in Redis will immediately drop from 5 to 3
There actually wasn't an issue with version 3 ether. It is the ETA tasks as a worker needs to increase the time counter. So the first worker who's up will usually consume all eta tasks and count them.
Activity
ask commentedon Mar 24, 2014
You're probably mistaking the pool child process pipe buffer with the broker prefetch limits. Disabling the latter would mean the worker slurps in as many messages as it can without limit.
ask commentedon Mar 24, 2014
http://docs.celeryproject.org/en/latest/userguide/optimizing.html#prefetch-limits vs http://docs.celeryproject.org/en/latest/userguide/optimizing.html#prefork-pool-prefetch-settings
frasergraham commentedon Mar 24, 2014
My workers have a single process, and can only safely do one task at a time. That task can take anywhere from 2 minutes to three hours. Is ACKS_LATE my only option for preventing a short task from being stuck behind a long task?
ask commentedon Mar 31, 2014
Yes, the worker is "subscribing to messages" not polling. You would have to move to using the synchronous amqp method basic.get to get a different behavior, but that would also mean you would have to sacrifice response time (or go into a very fast polling loop)
wolever commentedon Oct 26, 2015
I've run some experiments, and at least with Celery 3.1.15 and the Redis broker, neither
-OfairnorCELERYD_PREFETCH_MULTIPLIER = 1disable prefetching.To demonstrate this:
CELERYD_PREFETCH_MULTIPLIER = 1time.sleep(5))watch redis-cli -c llen defaultcelery worker -c 1 -Ofair5to3The worker is definitely prefetching one task.
Cediddi commentedon Jun 10, 2016
I'm also having the exact issue @wolever 's having. Could you solve your issue David, if so, how did you solve it?
codingjoe commentedon Aug 15, 2016
Same here
Cediddi commentedon Nov 4, 2016
Seems like 4.0 does solve this issue. I'm on rc7 and the default behavior is really -Ofair.
codingjoe commentedon Nov 5, 2016
There actually wasn't an issue with version 3 ether. It is the ETA tasks as a worker needs to increase the time counter. So the first worker who's up will usually consume all eta tasks and count them.