Skip to content

-Ofair doesn't disable prefetching #1933

Closed

Description

@frasergraham

The docs for 3.1 claim:

"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?

Activity

  1. ask commented on Mar 24, 2014

    @ask
    Contributor

    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.

  2. frasergraham commented on Mar 24, 2014

    @frasergraham
    Author

    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?

  3. ask commented on Mar 31, 2014

    @ask
    Contributor

    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)

  4. wolever commented on Oct 26, 2015

    @wolever

    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:

    1. Set CELERYD_PREFETCH_MULTIPLIER = 1
    2. Queue up 5 tasks that will each take a few seconds (ex, time.sleep(5))
    3. Start watching the length of the task queue in Redis: watch redis-cli -c llen default
    4. Start celery worker -c 1 -Ofair
    5. Notice that the queue length in Redis will immediately drop from 5 to 3

    The worker is definitely prefetching one task.

  5. Cediddi commented on Jun 10, 2016

    @Cediddi

    I'm also having the exact issue @wolever 's having. Could you solve your issue David, if so, how did you solve it?

  6. codingjoe commented on Aug 15, 2016

    @codingjoe

    Same here

  7. Cediddi commented on Nov 4, 2016

    @Cediddi

    Seems like 4.0 does solve this issue. I'm on rc7 and the default behavior is really -Ofair.

  8. codingjoe commented on Nov 5, 2016

    @codingjoe

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions