[Fixed]-Django celery tasks in separate server

26👍

You have 2 servers, 1 project and 2 settings(1 per server).

server A (web server + rabbit)

server B (only celery for workers)

Then you set up the broker url in both settings. Something like this:

BROKER_URL = 'amqp://user:password@IP_SERVER_A:5672//' matching server A to IP of server A in server B settings.

For now, any task must be sent to rabbit in server A to virtual server /.

In server B, you must just initialize celery worker, something like this:

python manage.py celery worker -Q queue_name -l info

and thats it.

Explanation: django sends messages to rabbit to queue a task, then celery workers request some message to execute a task.

Note: Is not required that rabbitMQ have to be installed in server A, you can install rabbit in server C and reference it in the BROKER_URL in both settings(A and B) like this: BROKER_URL='amqp://user:password@IP_SERVER_C:5672//'.

Sorry for my English.

greetings.

Leave a comment