Background Tasks
Some of the Saleor’s functionality depends on a task queue system to manage asynchronous and periodic tasks. We recommend using Redis as the message broker. For more information, please visit official Celery documentation.
Periodic tasks​
Saleor uses Celery Beat as a scheduler to trigger background tasks at regular intervals. The task scheduler is required for proper operation.
- Make sure the
CELERY_BROKER_URL
environment variable is set for all services and points to the task broker. Again, we recommend using Redis as a broker database.
set CELERY_BROKER_URL="<broker url>"
An example of the Redis broker url, running on localhost and port 6379, looks like: redis://localhost:6379/0
.
- Using the same container image, deploy Celery Workers by overriding the default command with:
celery --app saleor.celeryconf:app worker -E --loglevel=info
- Deploy exactly one instance of Celery Beat by overriding the default command with:
celery --app saleor.celeryconf:app beat --scheduler saleor.schedulers.schedulers.DatabaseScheduler
Task Schedule​
Below is a list of periodic tasks that Saleor runs, provided as a reference.
Tasks run in intervals:​
- Deactivate preorder for variants: every 1 hour
- Delete empty allocations: every 1 hour
- Delete expired reservations: every 1 day
- Delete outdated event data: every 1 day
- Expire orders: every 5 minutes
- Recalculate price for catalog promotions: every 30 seconds
- Release funds for abandoned checkouts: every 10 minutes
- Remove apps marked as removed: every 3 hours
- Update search vectors: every 20 seconds
Tasks run at specific time:​
- Deactivate expired gift cards: at 0:00 AM
- Delete expired checkouts: at 0:00 AM
- Delete expired orders: at 2:00 AM
- Delete old exports files: once per day at 1:00 AM
- Update stocks quantity allocated: once per day at 0:00 AM
- Promotion toggle: based on promotion's start date and end date