简体   繁体   English

使用Amazon EC2的Autoscale Python Celery

[英]Autoscale Python Celery with Amazon EC2

I have a Celery Task-Manager to crunch some numbers for company analytics. 我有一个Celery任务管理器来处理公司分析的一些数字。

The Task-Manager and workers are hosted on an Amazon EC2 Linux Server. 任务管理器和工作人员托管在Amazon EC2 Linux服务器上。

I need to set up the system such if we send too many tasks to celery Amazon automatically sets up a new EC2 instance to run more workers and balances the load across these workers. 我需要设置系统,如果我们向芹菜发送太多任务,亚马逊会自动设置一个新的EC2实例来运行更多的工作人员并平衡这些工作人员的负载。

The services that I'm aware exist are the Amazon Autoscale and Amazon Load balancing services which seem like exactly what I want to use however, I'm not sure what the best way to configure the Celery is. 我所知道的服务是亚马逊自动缩放和亚马逊负载均衡服务,这似乎正是我想要使用的,但我不确定配置Celery的最佳方式是什么。

I think that I ought to have a celery "master" which is collecting all the tasks and a number of celery workers which execute them. 认为我应该有一个收集所有任务的芹菜“主人”和一些执行它们的芹菜工人。 As the number of tasks increases I want to add more workers. 随着任务数量的增加,我想增加更多的工作人员。 The way the autoscale works (by taking an AMI of the celery server) I think that I'm currently cloning the Master as well as the workers which seems like not what I want to do. 自动缩放的工作方式(通过服用芹菜服务器的AMI)我认为我正在克隆Master和工作人员,这似乎不是我想做的事情。

How do I organise this to achieve my end goal which is flexible autoscaling task management using Celery to manage the tasks and Amazon Web Service to host the computing. 我如何组织这个以实现我的最终目标,即使用Celery管理任务和Amazon Web Service来托管计算的灵活的自动缩放任务管理。

As much detail as possible in any answers (or links to tutorials!) would be greatly appreciated as most tutorials or advice seems to assume large quantities of knowledge which I don't currently have! 因为大多数教程或建议似乎都假设我目前没有大量的知识,所以在任何答案(或教程的链接!)中尽可能详细的细节将非常受欢迎!

You do not need a master-worker architecture to get this to work. 您不需要使用master-worker体系结构来实现此功能。 If I understand your question correctly, you want to be able to scale based on queue size. 如果我正确理解您的问题,您希望能够根据队列大小进行扩展。 I would say it will be easier if you have the following steps 我会说如果你有以下步骤会更容易

  1. Setup elasticache / sqs for the broker (since you're in aws) 为代理设置elasticache / sqs (因为你在aws中)
  2. For custom scaling - A periodic task which checks queue sizes using something like this OR add amazon autoscaling to just add/remove machines when CPU usage is high (assuming that that is a good enough indication of load). 对于自定义缩放 - 使用类似这样的东西检查队列大小的周期性任务或者在CPU使用率高时添加amazon自动缩放以仅添加/删除机器(假设这是足够好的负载指示)。 Also, start workers with --autoscale so that the CPU usage gets reflected correctly. 此外,使用--autoscale启动工作程序,以便正确反映CPU使用情况。

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

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