分享

celery完全取消预取

 木棉下的守望 2019-03-04

首先贴链接https:///questions/16040039/understanding-celery-task-prefetching/33357180#33357180

在使用celery中,由于每个任务执行的时间很长,在这个任务后面预取等待的同一个worker任务会持续等待前面的任务执行完之后才能执行,即使其他的worker空闲了也不能取这个阻塞等待的任务来执行,所以取消预取。

只设置Ofair 参数发现预取仍然存在。按如下配置解决预取失效:

  1. Set CELERYD_PREFETCH_MULTIPLIER = 1

  2. Set CELERY_ACKS_LATE = True at a global level or task level

  3. Use -Ofair while starting the workers

  4. If you set concurrency to 1, then step 3 is not needed. If you want a higher concurrency, then step 3 is essential to avoid tasks getting backed up in a node that could be run long running tasks.

搜索

复制

    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多