简体   繁体   English

django-celery在多服务器生产环境中

[英]django-celery in multiple server production environment

I trying to deploy a django project using django, but I have these questions unsolved: 我尝试使用django部署django项目,但我没有解决这些问题:

  • Should I run one celeryd for each web server? 我应该为每个Web服务器运行一个celeryd吗?
  • Should I run just one RabbitMQ server, on another machine (not) running celeryd there, accesible to all my web servers? 我应该只运行一台RabbitMQ服务器,在那台运行celeryd的另一台机器(不是)上,可以访问我的所有网络服务器吗? or RabbitMQ must be run also on each of the web servers? 还是必须在每个Web服务器上运行RabbitMQ?
  • How can I use periodic tasks if the code is the same in all web servers? 如果所有Web服务器中的代码相同,我如何使用定期任务?

Thank for your answers. 谢谢你的回答。

It really depends on the size of the project, ideally you have RabbitMq, celery workers and web workers running on different machines. 这实际上取决于项目的大小,理想情况下,你有RabbitMq,芹菜工人和在不同机器上运行的网络工作者。

You need only one RabbitMQ and eventually multiple queue workers (bigger queues need more workers of course). 您只需要一个RabbitMQ,最终需要多个队列工作者(当然,更大的队列需要更多的工作人员)。

You dont need 1 celery worker per webworker, the webworkers are going to publish tasks to the broker and then the workers will get them from there, in fact the webworker does not care about the amount of workers connected to the broker as it only communicates with the broker. 你不需要每个网络工作者1个芹菜工人,网络工作者将向经纪人发布任务,然后工人将从那里获得他们,事实上,网络工作者并不关心连接到经纪人的工作人员数量,因为它只与经纪人。

Of course if you are starting a project it makes sense to keep everything on the same hardware and keep budget low and wait for the traffic and the money to flow :) 当然,如果您正在开始一个项目,那么将所有内容保存在同一硬件上并保持低预算并等待流量和资金流动是有意义的:)

You want to have the same code on every running instance of your app, no matter if they are celery workers/ webservers or whatever. 您希望在应用程序的每个运行实例上都拥有相同的代码,无论它们是芹菜工人/网络服务器还是其他任何东西。

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

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