Celery RedBeat is a custom Celery Beat Scheduler that leverages Redis for persistent storage of scheduled tasks and their runtime metadata. It allows for dynamic creation, modification, and deletion of periodic tasks at runtime without requiring a restart of the Celery Beat service. This design provides fast startup times, even with a large number of tasks, and prevents multiple Beat instances from running simultaneously through a distributed lock mechanism. The current version is 2.3.3, and it maintains an active development and release cadence.
pip install celery-redbeatVerified import paths — ran on the pinned version, not inferred.
To get started, configure your Celery application to use `RedBeatScheduler` by setting `redbeat_redis_url` and specifying the scheduler when running `celery beat`. Tasks can be defined dynamically using `RedBeatSchedulerEntry` instances and saved to Redis. It's recommended to use a different Redis database for RedBeat than for your Celery broker.
Upgrade your Python environment to 3.8 or newer, or pin `celery-redbeat` to a version prior to 2.1.0.
Refer to the `celery-redbeat` documentation for version 0.10.0+ to adjust task definitions and scheduler configurations.
Ensure `redbeat_lock_key` is not `None` in production environments. Configure `redbeat_lock_timeout` appropriately (e.g., 5 times `CELERYBEAT_MAX_LOOP_INTERVAL`) for your application's recovery needs. Monitor Redis for lock key health.
Always configure `redbeat_redis_url` to point to a different Redis database (e.g., `redis://localhost:6379/1`) than your Celery broker/result backend (e.g., `redis://localhost:6379/0`).
Run Celery Beat and Celery Workers as separate processes. Monitor Celery worker queues and task execution times. Implement robust logging and monitoring for both Celery Beat and Redis connections. Consider clearing Redis keys and recreating tasks if the scheduler gets into a corrupted state.
To resolve this, inject the `username` directly into the connection keyword arguments via the `redbeat_redis_use_ssl` configuration option, as it allows arbitrary parameters to be passed to the Redis client constructor.
Example `celeryconfig.py` modification:
`app.conf.redbeat_redis_use_ssl = {'username': 'your_username', 'ssl': False}`Upgrade `celery-redbeat` to a version that is compatible with your Celery installation (e.g., `celery-redbeat` 0.10.0 or later for Celery 4.0+). `pip install --upgrade celery-redbeat`
Upgrade `celery-redbeat` to a version that officially supports Celery 5.x, or temporarily pin your Celery version to 4.x if an updated `celery-redbeat` is not yet available. `pip install --upgrade celery-redbeat`
Ensure that the `Celery` app instance, fully configured with `redbeat_redis_url` (or other Redis settings), is explicitly passed to the `RedBeatSchedulerEntry` constructor.
Example:
```python
from celery import Celery
from redbeat import RedBeatSchedulerEntry
app = Celery('my_app', broker='redis://localhost:6379/0', backend='redis://localhost:6379/1')
app.conf.redbeat_redis_url = 'redis://localhost:6379/1'
# ... define your task and schedule ...
interval = app.conf.beat_schedule['my_task']['schedule'] # Example, get from your defined schedules
entry = RedBeatSchedulerEntry('my_task_name', 'my_app.tasks.my_task', interval, app=app)
entry.save()
```