Skip to main content

Run Django Celery Workers

Celery is the most popular task queue for Django applications. This guide walks you through running Celery workers and the beat scheduler on Appliku.

Prerequisites

Before you begin, make sure you have:

  • A Django application with Celery configured
  • A message broker (Redis or RabbitMQ)
  • celery listed in your requirements.txt

Step 1: Provision a Message Broker

Celery requires a message broker to coordinate tasks between your web process and worker processes.

Go to your application in the Appliku dashboard and navigate to the Databases section. Provision either:

  • Redis (recommended for most use cases)
  • RabbitMQ (better for complex routing and high-throughput scenarios)

After provisioning, Appliku will automatically add the connection URL as an environment variable.

Step 2: Set the Broker URL

Add the CELERY_BROKER_URL environment variable in your application's Environment Variables tab. Set it to the connection URL of your provisioned broker:

# settings.py
import os

CELERY_BROKER_URL = os.environ.get("CELERY_BROKER_URL", "redis://localhost:6379/0")
tip

If you provisioned Redis through Appliku, the connection URL is available in the database details. Copy it and paste it as the value for CELERY_BROKER_URL.

Step 3: Add a Worker Process

In your application's Processes tab, add a new process for the Celery worker:

  • Process name: worker
  • Command:
celery -A myproject worker --loglevel=info

Replace myproject with your Django project name (the directory containing celery.py).

Step 4: Add a Beat Process (Optional)

If you use periodic tasks (e.g., with celery-beat or django-celery-beat), add another process:

  • Process name: beat
  • Command:
celery -A myproject beat --loglevel=info
note

Only run one beat process at a time. Running multiple beat instances will cause duplicate task execution.

Step 5: Deploy

Save your process configuration and deploy your application. Appliku will start the worker and beat processes alongside your web process.

Verifying It Works

Check the logs for your worker process in the Appliku dashboard or via SSH:

ssh app@<your-server-ip>
docker logs <app-worker-container>

You should see output indicating the worker has connected to the broker and is ready to process tasks.