Django-celery 状态已收到?
我通过django-celery(以rabbitmq作为后端)运行一些任务,这些任务非常耗时且占用CPU资源。
我有 2 个工作 Ec2 实例(一个是小型实例,另一个是高 cpu 中型实例)。
我已将小型实例设置为运行 1 个并发任务,将中型实例设置为运行 4 个并发任务。这对我来说效果很好。但有时,在 celery 监视器中,我看到小型实例正在处理一项任务,并且另外 2 个或 3 个任务处于“已接收”状态(分配给小型实例),而中型实例没有执行任何操作。理想情况下,中型实例优先于小型实例,但在这种情况下,如果小型实例处于并发状态,则任务应该转到中型实例。看来这个小实例的咬合力超出了它的咀嚼能力……就像给自己分配目前无法启动的任务一样。
有没有办法让worker只接受此时可以开始的任务?
屏幕截图: http://dl.dropbox.com/u/361747/task-state .png 。以domU开头的worker为小型,以ip开头的为中型。
Im running some tasks via django-celery (with rabbitmq as backend), the tasks are time consuming and cpu intensive.
I got 2 worker Ec2 instances (One is small and other is high cpu medium).
Ive set the small instance to run 1 concurrent task, and the medium to do 4. This works well for me. But occasionally, in the celery monitor, I see that the small instance is working on a task and 2 or 3 more tasks are in "RECEIVED" state(assigned to the small instance), while the medium instance is not doing anything. Ideally id like the medium instance to have preference over the small, but in this case if small is at its concurrency the task should goto the medium. It seems the small instance is biting more than it can chew.. as in allocating tasks to itself which it cant start at the moment.
Is there a way to make workers accept only the tasks it can start at that moment?
Screenshot : http://dl.dropbox.com/u/361747/task-state.png . The worker starting with domU is the small, the one starting with ip is medium.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 CELERYD_PREFETCH_MULTIPLIER 选项来控制预取的任务数量。在您的情况下,CELERYD_PREFETCH_MULTIPLIER=1 将有助于均匀分配任务。
http://ask.github.com/celery/configuration.html#celeryd -预取乘数
You can use CELERYD_PREFETCH_MULTIPLIER option to control how many tasks to prefetch. In your case CELERYD_PREFETCH_MULTIPLIER=1 will help evenly distribute tasks.
http://ask.github.com/celery/configuration.html#celeryd-prefetch-multiplier