Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Supervisor + Django + Celery with multiple Queues and Workers?

I'm using Celery + Django + Supervisord and I'm trying to setup a "priority" by creating 3 different queues (as suggested at https://stackoverflow.com/a/15827160/54872).

Is there a way to start celery beat and workers for each queue in one command for supervisor? Or, do I need to make different supervisor conf files for each queue/worker pool and one for celery beat?

like image 556
landyman Avatar asked Aug 01 '13 18:08

landyman


People also ask

How does Celery handle concurrency?

As for --concurrency celery by default uses multiprocessing to perform concurrent execution of tasks. The number of worker processes/threads can be changed using the --concurrency argument and defaults to the number of available CPU's if not set.

How would you integrate Celery into a Django project and create periodic tasks?

Integrate Celery into a Django app and create tasks. Write a custom Django Admin command. Schedule a custom Django Admin command to run periodically via Celery Beat.

How does Celery define workers?

When you run a celery worker, it creates one parent process to manage the running tasks. This process handles the book keeping features like sending/receiving queue messages, registering tasks, killing hung tasks, tracking status, etc.

What is soft time limit in Celery?

Time Limits The time limit is set in two values, soft and hard . The soft time limit allows the task to catch an exception to clean up before it is killed: the hard timeout isn't catch-able and force terminates the task.


1 Answers

You can create program sections for each queue and combine them in a group section:

[program:worker1]
command=celery worker --queues=queue1

[program:worker2]
command=celery worker --queues=queue2

[group:workers]
programs=worker1,worker2
like image 187
mher Avatar answered Oct 04 '22 09:10

mher