如何使用 celery 配置不同的工作池?
我需要部署一个排队执行服务(通常)具有以下三类工作人员:
周期性的、低优先级的作业类,需要很长时间并且可以串行处理;这些作业最多只能使用系统中的 0..2 个工人。
定期的、对截止日期敏感的作业类别,需要短到中等的时间(例如,在 5 分钟达到顶峰)
一个临时工作类别,其优先级高于#1,但可以与#2 交错。当这种类型的工作出现时,来自类 #2 的任何不活动的工人都应该处理它,而不会导致工人池挨饿 #2
所有三个工作类别都是相同的任务,它们之间的唯一区别是它们的请求方式;它们将采用相同的输入并生成相同的输出,但每个都有不同的性能保证。
我如何使用芹菜来实现这个?
I need to deploy a queued execution service with (generally) the following three classes of worker:
A periodic, low-priority job class that takes a long time and can be processed serially; these jobs should only use 0..2 workers in the system at most.
A periodic, deadline-sensitive job class that take a short to medium amount of time (say, topping out at 5 minutes)
An ad-hoc job class, that is higher priority than #1, but can interleave with #2. Any workers from class #2 that are inactive when this type of job comes in should handle it, without ever starving the pool of workers for #2
All three job classes are the same task, the only difference between them is how they're requested; they'll take the same input and generate the same output, but each one has different performance guarantees.
How can I implement this using celery?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 Celery 路由 来实现您的目标。您要做的就是设置三个不同的路由键,并让多个 celery 工作人员(具有自定义配置)仅列出您设置的特定路由键。
You can use Celery Routing to achieve your goal. What you do is setup three different routing keys and have multiple celery workers (with custom configs) listing only on the specific routing keys you set up.