简体   繁体   English

根据可用RAM使用python / celery /任何其他任务队列调度任务

[英]Scheduling tasks with python/celery/any other task queue based on available RAM

Is there a way to get Celery to allocate tasks to workers based on available RAM? 有没有办法让Celery根据可用的RAM向工作人员分配任务? I am developing a web app which applies memory hungry algorithms to large in-memory data, is there a way to make this more robust using Celery to respect available RAM? 我正在开发一个将内存消耗算法应用于大型内存数据的Web应用程序,有没有办法使用Celery尊重可用的RAM,使其变得更加健壮?

Allocating tasks to workers based on available RAM is not possible. 无法根据可用RAM将任务分配给工作人员。 But, depending on your setup and exact requirements there are ways to work address this problem. 但是,根据您的设置和确切的要求,有一些方法可以解决此问题。 Off the top of my head I can think of: 我能想到的是:

  • you run one worker (and nothing else) on a machine with loads of RAM and have this worker process these memory-hungry tasks only 您在装有RAM的计算机上运行一个工作程序(没有其他操作),并且让该工作程序仅处理这些需要大量内存的任务
  • if you know how much memory you need for processing a task, you could check if that memory is available as a first step in your task (assuming that not much else runs on that box which could use up that memory in between the check and the actual running of your memory-hungry stuff) and if not, you can retry the task after a certain time 如果您知道处理任务需要多少内存,则可以检查该内存是否可以用作任务的第一步(假设在该框中没有其他可用的内存,这可能会在检查和检查之间耗尽该内存)。实际运行需要大量内存的东西),如果没有,可以在一定时间后重试该任务

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM