首先贴链接https:///questions/16040039/understanding-celery-task-prefetching/33357180#33357180 在使用celery中,由于每个任务执行的时间很长,在这个任务后面预取等待的同一个worker任务会持续等待前面的任务执行完之后才能执行,即使其他的worker空闲了也不能取这个阻塞等待的任务来执行,所以取消预取。 只设置Ofair 参数发现预取仍然存在。按如下配置解决预取失效: Set CELERYD_PREFETCH_MULTIPLIER = 1 Set CELERY_ACKS_LATE = True at a global level or task level Use -Ofair while starting the workers 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.
|