简体   繁体   中英

How to set up celery workers on separate machines?

I am new to celery.I know how to install and run one server but I need to distribute the task to multiple machines. My project uses celery to assign user requests passing to a web framework to different machines and then returns the result. I read the documentation but there it doesn't mention how to set up multiple machines. What am I missing?

My understanding is that your app will push requests into a queueing system (eg rabbitMQ) and then you can start any number of workers on different machines (with access to the same code as the app which submitted the task). They will pick out tasks from the message queue and then get to work on them. Once they're done, they will update the tombstone database.

The upshot of this is that you don't have to do anything special to start multiple workers. Just start them on separate identical (same source tree) machines.

The server which has the message queue need not be the same as the one with the workers and needn't be the same as the machines which submit jobs. You just need to put the location of the message queue in your celeryconfig.py and all the workers on all the machines can pick up jobs from the queue to perform tasks.

The way I deployed it is like this:

  1. clone your django project on a heroku instance (this will run the frontend)
  2. add RabitMQ as an add on and configure it
  3. clone your django project into another heroku instance (call it like worker) where you will run the celery tasks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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