开发者

Implementing "idle" and "normal" priority queues for long-running tasks in Celery

开发者 https://www.devze.com 2023-04-05 07:25 出处:网络
I\'m attempting to implement a following scenario with Celery: two queues of (same) long-running tasks, one for \"normal\" and the other for \"idle\" priority.

I'm attempting to implement a following scenario with Celery: two queues of (same) long-running tasks, one for "normal" and the other for "idle" priority.

I'd make the workers monitor both queues and take tasks from the "normal" priority queue first and if it's empty, it'd take tasks from the "idle" priority.

My question is: Is it possible to guarantee the order in which the workers will check their tasks queues? Also, is this the right approach for implementing priorities?

Background: The tasks are running ffmpeg transcoding jobs. The "normal" priority ones would be new videos coming in (which have to be transcoded ASAP) and the "idle" prior开发者_Python百科ity would be the tasks to re-transcode old (40.000+ video) archive to updated format settings. I do not have several servers available to do multi-server task dispatching.


Under the theory that idle workers are not consuming much system resources, I have implemented two priorities with a second exchange, a second set of queues, and a second set of workers. I don't have such intensive work processes so I don't make my second set of workers throttle themselves when the first set is active, but possible the UNIX renice command would work for this.

You could probably also do something with a control queue so that it is not sufficient for workers to receive a work request, they also need to get a token from a control queue. Then you spit out a small number of tokens to the idle control queue but a larger number of tokens to the normal control queue.


Docs:

  • http://ask.github.com/celery/faq.html#does-celery-support-task-priorities
  • http://ask.github.com/celery/userguide/executing.html#amqp-options

Also:

  • Workaround for celery task priority on RabbitMQ?
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号