芹菜+ REDIS如何基于最低时间戳以相同的优先级运行任务
我已经在芹菜中定义了一个任务,并使用烧瓶框架被称为。我看到芹菜能够在工作节点上执行任务。现在可以说,一些API以这种方式称为任务。
timestamp, task_id, priority
(t0, task1, P0)
(t1, task2, P0)
(t2, task3, P1)
当我监视任务状态时,有时我会看到任务2在任务1之前完成。我如何可靠地期望芹菜先完成任务1,然后选择任务2,因为Task1在Task2之前提交。
请让我知道。
I have defined a task in celery and it been called using flask framework. I see the celery is able to execute the tasks on worker node. Now lets say some API called the tasks in this fashion.
timestamp, task_id, priority
(t0, task1, P0)
(t1, task2, P0)
(t2, task3, P1)
When I monitor the task status sometimes I see that task2 is finishing before the task1. How can I reliably expect the celery to finish the task1 first then it should pick task2 as task1 was submitted before task2.
Kindly let me know.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您正在使用Redis,那么芹菜队列优先级的保证是,第一个到达的任务将首先从队列中取出首先(并且,大概是首先开始),而不是首先到达任务 finish finish < /strong>首先。如果要保证任务按收到的顺序完成,则必须(1)确保只有一个工人消耗队列,(2)SET
worker_prefetch_multipliper
to 1和1 (3)将同时发生设置为1启动工人时。Assuming you are using redis, what celery queue prioritization guarantees is that the first arriving tasks will be taken off the queue first (and, roughly speaking start first), not that first arriving tasks finish first. If you want to guarantee that tasks finish in the order that they are received, you have to (1) ensure that there is only one worker consuming off the queue, (2) set
worker_prefetch_multiplier
to 1, and (3) set concurrency to 1 when the worker is started.