Celery Flower
Flower is a real-time web-based monitor and administration tool for Celery distributed task queues. It provides a visual dashboard for task progress and history, worker status, remote control capabilities (e.g., shutdown workers, control pool size), and an HTTP API. It is actively developed and is the recommended monitoring solution for Celery clusters.
Warnings
- breaking Upgrading Celery to version 5.0.0 (and potentially later minor versions in the 5.x series) previously caused `ImportError: cannot import name 'Command' from 'celery.bin.base'` in Flower. This was due to internal API changes within Celery.
- gotcha Flower's default persistence for task history uses Python's `shelve` module, which is primarily in-memory and can lead to complete loss of task history upon Flower restarts or crashes. It also doesn't scale well with a large number of tasks or workers.
- gotcha Flower is exposed without any authentication by default, making it vulnerable if deployed publicly without proper security measures. This can expose sensitive task and worker information.
- gotcha When using RabbitMQ as a broker, especially with cloud providers like CloudAMQP, the 'Broker' tab in Flower might not function correctly or show all details without explicitly providing the RabbitMQ HTTP API URL.
Install
-
pip install flower
Imports
- Flower (command-line tool)
celery --broker=BROKER_URL flower
Quickstart
import os
from celery import Celery
# 1. Set up a simple Celery app
app = Celery(
'my_app',
broker=os.environ.get('CELERY_BROKER_URL', 'redis://localhost:6379/0'),
backend=os.environ.get('CELERY_BACKEND_URL', 'redis://localhost:6379/0')
)
@app.task
def add(x, y):
return x + y
# To run Celery worker (in a separate terminal):
# celery -A my_app worker --loglevel=info
# To run Flower (in another separate terminal):
# celery -A my_app flower --port=5555
# Or, if not using an app instance directly:
# celery --broker=redis://localhost:6379/0 flower --port=5555
# Then open http://localhost:5555 in your browser.